feat: Implement budget edit functionality

When the "Edit Budget" button is clicked, display a popup similar to the expense input form for budget modification.
This commit is contained in:
gpt-engineer-app[bot]
2025-04-05 05:41:15 +00:00
parent 45df7c368a
commit 62551d58e3
5 changed files with 159 additions and 105 deletions

View File

@@ -1,14 +1,27 @@
/**
* 금액 포맷 유틸리티
*/
// 금액을 한국 원화 형식으로 포맷팅
export const formatCurrency = (amount: number): string => {
return new Intl.NumberFormat('ko-KR', {
style: 'currency',
currency: 'KRW',
maximumFractionDigits: 0
}).format(amount);
return amount.toLocaleString('ko-KR') + '원';
};
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);
// 숫자 문자열에서 쉼표 제거
export const removeCommas = (value: string): string => {
return value.replace(/,/g, '');
};
// 숫자 문자열에 쉼표 추가
export const addCommas = (value: string): string => {
// 숫자 이외의 문자는 제거
const numericValue = value.replace(/[^\d]/g, '');
return numericValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
};
// 금액 입력 값 포맷팅 (입력 필드용)
export const formatWithCommas = (value: string): string => {
// 기존 쉼표 제거 후 다시 포맷팅
return addCommas(removeCommas(value));
};