From ce3c3e8e3fa299b3e18c972bb545a8ff05b7ae55 Mon Sep 17 00:00:00 2001 From: TBardini Date: Mon, 30 Sep 2024 13:55:10 -0400 Subject: [PATCH] fix: updated Zod types for usage_data and refactored type imports --- .../CaseSummaryComponents/AnalysisHeader.tsx | 18 ++++++------------ .../CaseSummaryComponents/EnergyUseHistory.tsx | 4 ++-- .../EnergyUseHistoryChart.tsx | 4 ++-- heat-stack/types/types.ts | 2 +- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/heat-stack/app/components/ui/heat/CaseSummaryComponents/AnalysisHeader.tsx b/heat-stack/app/components/ui/heat/CaseSummaryComponents/AnalysisHeader.tsx index 227d366f..755a9d48 100644 --- a/heat-stack/app/components/ui/heat/CaseSummaryComponents/AnalysisHeader.tsx +++ b/heat-stack/app/components/ui/heat/CaseSummaryComponents/AnalysisHeader.tsx @@ -1,13 +1,7 @@ import { type z } from 'zod'; -import { usageDataSchema, BillingRecordsSchema, SummaryOutputSchema } from '#types/index' +import { type UsageDataSchema } from '#/types/types.ts'; - -// type HeatLoadAnalysisZod = z.infer -type usageDataZod = z.infer -type BillingRecordsZod = z.infer -type SummaryOutputZod = z.infer - -export function AnalysisHeader({ usage_data }: { usage_data: usageDataZod}) { +export function AnalysisHeader({ usage_data }: { usage_data: UsageDataSchema}) { // Example usage_data // new Map([[ // "estimated_balance_point", @@ -39,21 +33,21 @@ export function AnalysisHeader({ usage_data }: { usage_data: usageDataZod}) { // ]]) // Extract the summary_output from usage_data - const summaryOutputs: SummaryOutputZod | undefined = usage_data?.summary_output; + const summaryOutputs = usage_data?.summary_output; // Calculate the number of billing periods included in Heating calculations const heatingAnalysisTypeRecords = usage_data?.billing_records?.filter( - (billingRecord: BillingRecordsZod) => billingRecord.analysis_type === 1, + (billingRecord) => billingRecord.analysis_type === 1, ); const recordsIncludedByDefault = heatingAnalysisTypeRecords?.filter( - (billingRecord:BillingRecordsZod) => + (billingRecord) => billingRecord.default_inclusion_by_calculation === true && billingRecord.inclusion_override === false, ).length; const recordsIncludedByOverride = heatingAnalysisTypeRecords?.filter( - (billingRecord: BillingRecordsZod) => + (billingRecord) => billingRecord.default_inclusion_by_calculation === false && billingRecord.inclusion_override === true, ).length; diff --git a/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistory.tsx b/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistory.tsx index e9ccc417..9d584b88 100644 --- a/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistory.tsx +++ b/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistory.tsx @@ -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 { type UsageDataSchema } from '#/types/types.ts'; import { AnalysisHeader } from './AnalysisHeader.tsx' import { EnergyUseHistoryChart } from './EnergyUseHistoryChart.tsx' @@ -14,7 +14,7 @@ import { EnergyUseHistoryChart } from './EnergyUseHistoryChart.tsx' export function EnergyUseHistory({ usage_data, }: { - usage_data: usageDataSchema + usage_data: UsageDataSchema }) { const titleClass = 'text-5xl font-extrabold tracking-wide mt-10' // const subtitleClass = 'text-2xl font-semibold text-zinc-950 mt-9' diff --git a/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistoryChart.tsx b/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistoryChart.tsx index 4b825e62..12934832 100644 --- a/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistoryChart.tsx +++ b/heat-stack/app/components/ui/heat/CaseSummaryComponents/EnergyUseHistoryChart.tsx @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' import { type z } from 'zod' -import { type usageDataSchema, BillingRecordsSchema } from '#/types/types.ts' +import { type UsageDataSchema, type BillingRecordsSchema } from '#/types/types.ts'; import { NaturalGasUsageData, type NaturalGasBillRecord as NaturalGasBillRecordZod, @@ -58,7 +58,7 @@ import { tr } from '@faker-js/faker' // naturalGasBillRecord04, // ] -export function EnergyUseHistoryChart({ usage_data }: { usage_data: usageDataSchema }) { +export function EnergyUseHistoryChart({ usage_data }: { usage_data: UsageDataSchema }) { const [billingRecords, setBillingRecords] = useState([]) useEffect(() => { diff --git a/heat-stack/types/types.ts b/heat-stack/types/types.ts index baa10abc..1cd2f32f 100644 --- a/heat-stack/types/types.ts +++ b/heat-stack/types/types.ts @@ -13,4 +13,4 @@ export type BalancePointGraphSchema = z.infer; export type SummaryOutputSchema = z.infer; export type BillingRecordSchema = z.infer; export type BillingRecordsSchema = z.infer; -export type usageDataSchema = z.infer; \ No newline at end of file +export type UsageDataSchema = z.infer; \ No newline at end of file