From a2025bba133905a1265feef685675d8f1e3590d1 Mon Sep 17 00:00:00 2001 From: "mihailo.vojinovic" Date: Fri, 13 Feb 2026 12:51:27 +0100 Subject: Show currency correctly --- src/components/invoice-generator.tsx | 69 ++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/src/components/invoice-generator.tsx b/src/components/invoice-generator.tsx index 792dfbc..43ce9ee 100644 --- a/src/components/invoice-generator.tsx +++ b/src/components/invoice-generator.tsx @@ -9,10 +9,9 @@ import { SubmitHandler, } from "react-hook-form"; import { Input } from "./ui/input"; -import React, { useActionState } from "react"; +import React from "react"; import { cn } from "@/utils/cn"; import { Button } from "./ui/button"; -import { generateInvoiceAction } from "@/lib/actions"; import { generateInvoice } from "@/lib/generate"; const defaultItem = { @@ -113,12 +112,11 @@ export const InvoiceGenerator = () => {

Item

Quantity

Rate

-

Amount

-

Actions

+

Amount

-
+
{fields.map((f, ind) => ( - +
{ -

- {(lineItems[ind]?.rate ?? 0) * (lineItems[ind]?.quantity ?? 0)}{" "} - {currency} -

- - +
+

+ {( + (lineItems[ind]?.rate ?? 0) * (lineItems[ind]?.quantity ?? 0) + ).toLocaleString(undefined, { style: "currency", currency })} +

+ +
+
))} -
-
+
Subtotal:{" "} - {lineItems.reduce( - (acc, cur) => acc + (cur.rate ?? 0) * (cur.quantity ?? 0), - 0, - )}{" "} - {currency} + + {lineItems + .reduce( + (acc, cur) => acc + (cur.rate ?? 0) * (cur.quantity ?? 0), + 0, + ) + .toLocaleString(undefined, { style: "currency", currency })} +
-
- +
+
); -- cgit v1.3.1