From e5376419692bc0ae99d8f8c4790ce222981f0853 Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Wed, 10 Jul 2024 02:55:47 +0800 Subject: [PATCH 1/2] Fix COE values crashing on string with comma separator --- app/components/MonthlyResult.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/components/MonthlyResult.tsx b/app/components/MonthlyResult.tsx index 95a8bd1..1e2d65e 100644 --- a/app/components/MonthlyResult.tsx +++ b/app/components/MonthlyResult.tsx @@ -20,14 +20,10 @@ export const MonthlyResult = ({ data }: MonthlyResultProps) => { ...new Set(filteredData.map(({ bidding_no }) => bidding_no)), ]; const chartCategories = filteredData.map((item) => item.vehicle_class); - const premium = filteredData.map((item) => parseInt(item.premium, 10)); - const bidsReceived = filteredData.map((item) => - parseInt(item.bids_received.replace(/,/g, ""), 10), - ); - const bidsSuccess = filteredData.map((item) => - parseInt(item.bids_success.replace(/,/g, ""), 10), - ); - const quotas = filteredData.map((item) => parseInt(item.quota, 10)); + const premium = filteredData.map((item) => item.premium); + const bidsReceived = filteredData.map((item) => item.bids_received); + const bidsSuccess = filteredData.map((item) => item.bids_success); + const quotas = filteredData.map((item) => item.quota); const graphTitle = ({ month, From 04cab784883babb5950e58f29220e12860717519 Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Wed, 10 Jul 2024 02:59:50 +0800 Subject: [PATCH 2/2] Fix types --- app/components/HistoricalResult.tsx | 2 +- types/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/HistoricalResult.tsx b/app/components/HistoricalResult.tsx index 7e17db2..d2cb84b 100644 --- a/app/components/HistoricalResult.tsx +++ b/app/components/HistoricalResult.tsx @@ -28,7 +28,7 @@ export const HistoricalResult = ({ data }: HistoricalResultProps) => { monthsSet.add(month); quotaPremiumMap[vehicle_class] = { ...quotaPremiumMap[vehicle_class], - [month]: parseInt(premium, 10), + [month]: premium, }; }); diff --git a/types/index.ts b/types/index.ts index 416a85b..8633c73 100644 --- a/types/index.ts +++ b/types/index.ts @@ -30,8 +30,8 @@ export interface COEResult { month: string; bidding_no: string; vehicle_class: string; - quota: string; - bids_success: string; - bids_received: string; - premium: string; + quota: number; + bids_success: number; + bids_received: number; + premium: number; }