Fix NaN percentage display

Ensure percentage displays 0 instead of NaN when budget target is zero.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 23:11:27 +00:00
parent d798632d05
commit a0866492ac
2 changed files with 8 additions and 3 deletions

View File

@@ -8,5 +8,7 @@ export const formatCurrency = (amount: number): string => {
};
export const calculatePercentage = (spent: number, target: number): number => {
// 타겟이 0이면 0%를 반환하도록 수정
if (target === 0 || isNaN(target)) return 0;
return Math.min(Math.round(spent / target * 100), 100);
};