amount formatter

This commit is contained in:
2026-04-06 16:10:09 +05:30
parent 2979634033
commit 234f86d6b9

View File

@@ -34,6 +34,23 @@ export default function HistoryChart({
const maxAmount = Math.max(...currentData.map((d) => d.amount), 1);
// ✅ Formatter (₹ + adaptive units)
const formatAmount = (amount: number) => {
const tab = activeTab.toLowerCase();
if (tab === "year") {
const lakhs = amount / 100000;
return `${lakhs.toFixed(2)} L`;
}
if (tab === "month") {
const thousands = amount / 1000;
return `${thousands.toFixed(1)} K`;
}
return `${amount.toLocaleString("en-IN")}`;
};
return (
<Paper sx={{ p: { xs: 2, sm: 4 }, borderRadius: 4, width: "100%", boxShadow: 'none', border: '1px solid', borderColor: 'divider' }}>
<Typography variant="h6" fontWeight={700} gutterBottom>
@@ -94,7 +111,7 @@ export default function HistoryChart({
}}
>
<Typography variant="caption" sx={{ mb: 1, opacity: 0.7, fontSize: '0.65rem', display: { xs: 'none', sm: 'block' } }}>
{point.amount > 0 ? `Rs ${point.amount}` : ''}
{point.amount > 0 ? formatAmount(point.amount) : ""}
</Typography>
<Box