refactor: update chart tooltip formatting and enhance currency formatter for consistency

This commit is contained in:
Yoga Pangestu 2026-04-23 20:40:54 +07:00
parent 50953e1c37
commit 861cd6d26f
3 changed files with 14 additions and 14 deletions

View File

@ -73,9 +73,9 @@ export function AovTrendChart({
content={ content={
<ChartTooltipContent <ChartTooltipContent
hideLabel hideLabel
formatter={(value) => [ formatter={(value, name) => [
formatCurrency(Number(value)), formatCurrency(Number(value)),
chartConfig.aov.label ` - ${chartConfig[name as keyof typeof chartConfig]?.label ?? name}`,
]} ]}
/> />
} }

View File

@ -1,15 +1,14 @@
"use client" "use client"
import { GitCommitVertical, TrendingUp } from "lucide-react" import { GitCommitVertical } from "lucide-react"
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts" import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
import { import {
Card, Card,
CardContent, CardContent,
CardDescription, CardDescription,
CardFooter,
CardHeader, CardHeader,
CardTitle, CardTitle
} from "@/components/ui/card" } from "@/components/ui/card"
import { import {
ChartContainer, ChartContainer,
@ -17,7 +16,6 @@ import {
ChartTooltipContent, ChartTooltipContent,
type ChartConfig, type ChartConfig,
} from "@/components/ui/chart" } from "@/components/ui/chart"
import { formatCurrency } from "@/lib/formatters"
export const description = "Menampilkan volume transaksi per bulan." export const description = "Menampilkan volume transaksi per bulan."
@ -28,14 +26,14 @@ const chartConfig = {
}, },
} satisfies ChartConfig } satisfies ChartConfig
export function TransactionVolumeChart({ export function TransactionVolumeChart({
data, data,
title = "Volume Transaksi", title = "Volume Transaksi",
description = "Total jumlah pesanan yang diproses per bulan." description = "Total jumlah pesanan yang diproses per bulan."
}: { }: {
data: any[], data: any[],
title?: string, title?: string,
description?: string description?: string
}) { }) {
return ( return (
<Card> <Card>

View File

@ -24,11 +24,13 @@ export const formatDate = (date: Date | string | undefined) => {
year: 'numeric', year: 'numeric',
}); });
}; };
export const formatCurrency = (value: number) => { export const formatCurrency = (value: number) => {
return new Intl.NumberFormat('id-ID', { return new Intl.NumberFormat('id-ID', {
style: 'currency', style: 'currency',
currency: 'IDR', currency: 'IDR',
minimumFractionDigits: 0, minimumFractionDigits: 0,
maximumFractionDigits: 0,
}).format(value); }).format(value);
}; };