Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Form lifecycle derek #294

Closed
wants to merge 9 commits into from
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Upload } from 'lucide-react'

import { Button } from '#/app/components/ui/button.tsx'
import { type UsageDataSchema } from '#/types/types.ts';
import { BillingRecordsSchema, type UsageDataSchema } from '#/types/types.ts';

Check warning on line 4 in heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistory.tsx

View workflow job for this annotation

GitHub Actions / ⬣ Heat-Stack - ESLint

All imports in the declaration are only used as types. Use `import type`
import { AnalysisHeader } from './AnalysisHeader.tsx'
import { EnergyUseHistoryChart } from './EnergyUseHistoryChart.tsx'

Expand All @@ -11,11 +11,17 @@
// import { Input } from '#/app/components/ui/input.tsx'
// import { Label } from '#/app/components/ui/label.tsx'

interface EnergyUseHistoryProps {
usage_data: UsageDataSchema;
recalculateFn: (billingRecords: BillingRecordsSchema) => void;
show_usage_data: boolean
}

export function EnergyUseHistory({
usage_data,
}: {
usage_data: UsageDataSchema
}) {
recalculateFn,
show_usage_data
}: EnergyUseHistoryProps) {
const titleClass = 'text-5xl font-extrabold tracking-wide mt-10'
// const subtitleClass = 'text-2xl font-semibold text-zinc-950 mt-9'

Expand All @@ -41,10 +47,10 @@
Get example file here
</a>

{usage_data && (
{show_usage_data && (
<>
<AnalysisHeader usage_data={usage_data} />
<EnergyUseHistoryChart usage_data={usage_data} />
<EnergyUseHistoryChart usage_data={usage_data} recalculateFn={recalculateFn}/>
</>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,19 @@
// naturalGasBillRecord04,
// ]

export function EnergyUseHistoryChart({ usage_data }: { usage_data: UsageDataSchema }) {
interface EngergyUseHistoryChartProps {
usage_data: UsageDataSchema
recalculateFn: (billingRecords: BillingRecordsSchema) => void;
}

export function EnergyUseHistoryChart({ usage_data, recalculateFn }: EngergyUseHistoryChartProps) {
const [billingRecords, setBillingRecords] = useState<BillingRecordsSchema>([])

useEffect(() => {
console.log('billing records changed, should trigger recalculation: ', billingRecords)
recalculateFn(billingRecords)
}, [billingRecords])

Check warning on line 68 in heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistoryChart.tsx

View workflow job for this annotation

GitHub Actions / ⬣ Heat-Stack - ESLint

React Hook useEffect has a missing dependency: 'recalculateFn'. Either include it or remove the dependency array. If 'recalculateFn' changes too often, find the parent component that defines it and wrap that definition in useCallback

useEffect(() => {
if (usage_data?.processed_energy_bills) {
// Process the billing records directly without converting from Map
Expand Down
Loading
Loading