From 538d933baef56d7ee76f78617b553d63713efa24 Mon Sep 17 00:00:00 2001 From: Biswa Kalyan Bhuyan Date: Sun, 27 Apr 2025 23:02:42 +0530 Subject: finance: feat: added the goal page with some improvements of ui --- frontend/src/lib/utils.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'frontend/src/lib/utils.ts') diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.ts index bd0c391..25e4a61 100644 --- a/frontend/src/lib/utils.ts +++ b/frontend/src/lib/utils.ts @@ -4,3 +4,17 @@ import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } + +export function formatCurrency(amount: number | null | undefined): string { + // Check if amount is null, undefined or NaN + if (amount === null || amount === undefined || isNaN(amount)) { + return '$0'; + } + + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + minimumFractionDigits: 0, + maximumFractionDigits: 0, + }).format(amount); +} -- cgit v1.2.3-59-g8ed1b