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:
@@ -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));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user