Fix NaN percentage display
Ensure percentage displays 0 instead of NaN when budget target is zero.
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user