diff --git a/src/app/api/store/[slug]/orders/route.ts b/src/app/api/store/[slug]/orders/route.ts index 55bb6794..d1e6d7c0 100644 --- a/src/app/api/store/[slug]/orders/route.ts +++ b/src/app/api/store/[slug]/orders/route.ts @@ -79,9 +79,9 @@ function generateOrderNumber(): string { * Format currency for display */ function formatCurrency(amount: number, currency: string = 'BDT'): string { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency, + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(amount); } diff --git a/src/components/analytics-dashboard.tsx b/src/components/analytics-dashboard.tsx index 0d7f3860..8809702f 100644 --- a/src/components/analytics-dashboard.tsx +++ b/src/components/analytics-dashboard.tsx @@ -95,9 +95,7 @@ export function AnalyticsDashboard({ storeId, dateRange }: AnalyticsDashboardPro // Format currency const formatCurrency = (amount: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(amount); diff --git a/src/components/analytics/analytics-dashboard.tsx b/src/components/analytics/analytics-dashboard.tsx index 230f6167..6eb1058c 100644 --- a/src/components/analytics/analytics-dashboard.tsx +++ b/src/components/analytics/analytics-dashboard.tsx @@ -146,9 +146,9 @@ export function AnalyticsDashboard({ storeId: propStoreId }: AnalyticsDashboardP }, [timeRange, storeId]); const formatCurrency = (value: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(value); }; diff --git a/src/components/analytics/customer-metrics.tsx b/src/components/analytics/customer-metrics.tsx index 89a2a932..7d4b1f3f 100644 --- a/src/components/analytics/customer-metrics.tsx +++ b/src/components/analytics/customer-metrics.tsx @@ -75,9 +75,9 @@ export function CustomerMetrics({ storeId, timeRange }: CustomerMetricsProps) { const formatCurrency = (value: number | undefined | null) => { if (value === null || value === undefined) return 'BDT 0.00'; - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(value); }; diff --git a/src/components/analytics/revenue-chart.tsx b/src/components/analytics/revenue-chart.tsx index aa2b7ac8..3ebb2234 100644 --- a/src/components/analytics/revenue-chart.tsx +++ b/src/components/analytics/revenue-chart.tsx @@ -88,10 +88,9 @@ export function RevenueChart({ storeId, timeRange }: RevenueChartProps) { } const formatCurrency = (value: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { minimumFractionDigits: 0, + maximumFractionDigits: 0, }).format(value); }; diff --git a/src/components/analytics/top-products-table.tsx b/src/components/analytics/top-products-table.tsx index 4ed752e7..30b73594 100644 --- a/src/components/analytics/top-products-table.tsx +++ b/src/components/analytics/top-products-table.tsx @@ -57,10 +57,9 @@ export function TopProductsTable({ storeId, timeRange }: TopProductsTableProps) }, [storeId, timeRange]); const formatCurrency = (value: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { minimumFractionDigits: 0, + maximumFractionDigits: 0, }).format(value); }; diff --git a/src/components/customers/customer-detail-dialog.tsx b/src/components/customers/customer-detail-dialog.tsx index 2c3c04aa..c9629bbf 100644 --- a/src/components/customers/customer-detail-dialog.tsx +++ b/src/components/customers/customer-detail-dialog.tsx @@ -44,9 +44,9 @@ export function CustomerDetailDialog({ onOpenChange, }: CustomerDetailDialogProps) { const formatCurrency = (value: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(value); }; diff --git a/src/components/customers/customers-list.tsx b/src/components/customers/customers-list.tsx index ae4de694..1ed1a114 100644 --- a/src/components/customers/customers-list.tsx +++ b/src/components/customers/customers-list.tsx @@ -150,9 +150,9 @@ export function CustomersList({ storeId }: CustomersListProps) { }; const formatCurrency = (value: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(value); }; diff --git a/src/components/order-detail-client.tsx b/src/components/order-detail-client.tsx index 2467b413..a1b29fc7 100644 --- a/src/components/order-detail-client.tsx +++ b/src/components/order-detail-client.tsx @@ -319,9 +319,9 @@ export function OrderDetailClient({ orderId, storeId }: OrderDetailClientProps) // Format currency const formatCurrency = (amount: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(amount); }; diff --git a/src/components/orders-table.tsx b/src/components/orders-table.tsx index 5b842e9b..f0784b4c 100644 --- a/src/components/orders-table.tsx +++ b/src/components/orders-table.tsx @@ -150,9 +150,9 @@ const paymentStatusColors: Record = { // Format currency const formatCurrency = (amount: number) => { - return new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'BDT', + return 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2, }).format(amount); }; diff --git a/src/components/orders/refund-dialog.tsx b/src/components/orders/refund-dialog.tsx index 8d706f98..8438655d 100644 --- a/src/components/orders/refund-dialog.tsx +++ b/src/components/orders/refund-dialog.tsx @@ -54,7 +54,10 @@ export function RefundDialog({ const refundableBalance = totalAmount - refundedAmount; const formatCurrency = (amount: number) => - new Intl.NumberFormat('en-US', { style: 'currency', currency: 'BDT' }).format(amount); + 'BDT ' + new Intl.NumberFormat('en-US', { + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }).format(amount); const handleRefund = async () => { setError(''); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index bf12c16c..a6c6ac7f 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -16,9 +16,7 @@ export function formatCurrency( currency: string = "BDT", locale: string = "en-US" ): string { - return new Intl.NumberFormat(locale, { - style: "currency", - currency, + return currency + ' ' + new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(amount / 100); // Assuming amounts are stored in paisa @@ -35,9 +33,7 @@ export function formatCurrencyFromTaka( currency: string = "BDT", locale: string = "en-US" ): string { - return new Intl.NumberFormat(locale, { - style: "currency", - currency, + return currency + ' ' + new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(amount);