diff --git a/webapp/app/[lang]/dashboard/billing/page.tsx b/webapp/app/[lang]/dashboard/billing/page.tsx index 93f60f5..0334215 100644 --- a/webapp/app/[lang]/dashboard/billing/page.tsx +++ b/webapp/app/[lang]/dashboard/billing/page.tsx @@ -1,10 +1,9 @@ -import CurrentBill from "@/app/components/dashboard/currentBill"; -import billingHistoryAPI from "@/app/apis/dummyMonthlyBillHistory"; -import MonthlyBillingHistory from "@/app/components/billing/MonthlyBillingHistory"; import { getDictionary } from "@/get-dictionary"; import { Locale } from "@/i18n-config"; import { Metadata } from "next"; import dummyBillApi from "../../../apis/dummyBillApi"; +import BillingSummaryPage from "@/app/components/billiing/billingSummaryPage"; +import billingHistoryAPI from "@/app/apis/dummyMonthlyBillHistory"; export const metadata: Metadata = { title: "Billing", @@ -18,18 +17,13 @@ export default async function BillingPage({ const customerBill = dummyBillApi.getBill(123); const billHistoryData = billingHistoryAPI.getBillingHistory(); - const dictionary = await getDictionary(lang); + const dictionary = await getDictionary(lang); return ( -
-

Pay My Bill

-
- - -
-
+ <> + {customerBill && ( + + )} + ); } diff --git a/webapp/app/apis/dummyBillApi/bill.json b/webapp/app/apis/dummyBillApi/bill.json index 4ee705c..a5c6bc6 100644 --- a/webapp/app/apis/dummyBillApi/bill.json +++ b/webapp/app/apis/dummyBillApi/bill.json @@ -4,13 +4,95 @@ "dueDate": "04/30/2025", "dueAmount": "$50", "fromDate": "03/01/2025", - "toDate": "03/31/2025" + "toDate": "03/31/2025", + "subTotal": "$45", + "billCharges": { + "Basic Service Charge": { + "units": "1", + "charge": "10" + }, + "Energy Charge Winter": { + "units": "1", + "charge": "10" + }, + "Fuel Cost Charge": { + "units": "1", + "charge": "10" + }, + "Sales True up": { + "units": "1", + "charge": "10" + } + }, + "billTaxes": { + "City Fees": { + "units": "1", + "charge": "10" + }, + "Transit Improvement Tax": { + "units": "1", + "charge": "10" + }, + "City Tax": { + "units": "1", + "charge": "10" + }, + "County Tax": { + "units": "1", + "charge": "10" + }, + "State Tax": { + "units": "1", + "charge": "10" + } + } }, { "customerId": 345, "dueDate": "05/30/2025", "dueAmount": "$30", "fromDate": "04/01/2025", - "toDate": "04/31/2025" + "toDate": "04/31/2025", + "subTotal": "$25", + "billDetails": { + "Basic Service Charge": { + "units": "1", + "charge": "10" + }, + "Energy Charge Winter": { + "units": "1", + "charge": "10" + }, + "Fuel Cost Charge": { + "units": "1", + "charge": "10" + }, + "Sales True up": { + "units": "1", + "charge": "10" + } + }, + "billTaxes": { + "City Fees": { + "units": "1", + "charge": "10" + }, + "Transit Improvement Tax": { + "units": "1", + "charge": "10" + }, + "City Tax": { + "units": "1", + "charge": "10" + }, + "County Tax": { + "units": "1", + "charge": "10" + }, + "State Tax": { + "units": "1", + "charge": "10" + } + } } ] diff --git a/webapp/app/components/billiing/billingSummaryPage.tsx b/webapp/app/components/billiing/billingSummaryPage.tsx new file mode 100644 index 0000000..a4d3402 --- /dev/null +++ b/webapp/app/components/billiing/billingSummaryPage.tsx @@ -0,0 +1,52 @@ +"use client"; +import { BillDetails, DictionaryType } from "@/types"; +import CurrentBill from "../dashboard/currentBill"; +import BillingSummary from "../dashboard/billingSummary"; +import { useState } from "react"; +import MonthlyBillingHistory from "../billing/MonthlyBillingHistory"; + +const BillingSummaryPage = ({ + dictionary, + billDetails, + billHistoryData, +}: { + dictionary: DictionaryType; + billDetails: BillDetails; + billHistoryData: any; +}) => { + const [showBillDetails, setShowBillDetails] = useState(false); + + return ( + <> +

+ {showBillDetails + ? dictionary.billings.billingDetails + : dictionary.billings.payMyBills} +

+
+ {billDetails && ( + <> + + {showBillDetails ? ( + + ) : ( + + )} + + )} +
+ + ); +}; + +export default BillingSummaryPage; diff --git a/webapp/app/components/dashboard/billingSummary.tsx b/webapp/app/components/dashboard/billingSummary.tsx new file mode 100644 index 0000000..c622b1b --- /dev/null +++ b/webapp/app/components/dashboard/billingSummary.tsx @@ -0,0 +1,95 @@ +import { BillDetails, DictionaryType } from "@/types"; + + + + +const TableView = ({ + data, +}: { + data: Record; +}) => { + return Object.keys(data)?.map((item, index) => { + const unit = data[item]?.units; + const charge = data[item]?.charge; + return ( +
+
+
{item}
+
+
+
{unit}
+
+
+
{charge}
+
+
+ ); + }); +}; + +const BillingSummary = ({ + dictionary, + billDetails, +}: { + dictionary: DictionaryType; + billDetails: BillDetails; +}) => { + const { fromDate, toDate } = billDetails; + return ( +
+

+ {dictionary.billings.summary} +

+
+

+ {`${dictionary.billings.utility_service} ${fromDate} - ${toDate}`} +

+ {billDetails?.billCharges && ( + <> +
+
+
Description
+
+
+
Units
+
+
+
Charge
+
+
+ + + )} +
+
+
SubTotal
+
+
+
+
+
+
{billDetails?.subTotal}
+
+
+
+ {billDetails?.billTaxes && } +
+
+
+
Total
+
+
+
+
+
+
{billDetails?.dueAmount}
+
+
+
+ ); +}; + +export default BillingSummary; diff --git a/webapp/app/components/dashboard/currentBill.tsx b/webapp/app/components/dashboard/currentBill.tsx index 65b307f..6d81304 100644 --- a/webapp/app/components/dashboard/currentBill.tsx +++ b/webapp/app/components/dashboard/currentBill.tsx @@ -1,27 +1,22 @@ import { Button } from "@/components/ui/button"; -import { DictionaryType } from "@/types"; - -class BillDetails { - customerId:number =1; - fromDate: string = "03/01/2025"; - toDate: string = "03/31/2025"; - dueDate: string = "03/30/2025"; - dueAmount: string = "$50"; -} +import { BillDetails, DictionaryType } from "@/types"; const CurrentBill = ({ dictionary, - billDetails = new BillDetails(), + billDetails, + setShowBillDetails, }: { dictionary: DictionaryType; - billDetails?: BillDetails; + billDetails: BillDetails; + setShowBillDetails?: (showBillDetails: boolean) => void; }) => { const { fromDate, toDate, dueDate, dueAmount } = billDetails; return (
-

+

{dictionary.billings.current_bill}

+

{`${dictionary.billings.utility_service} ${fromDate} - ${toDate}`}

@@ -42,7 +37,7 @@ const CurrentBill = ({