Refactor RecentTransactionsSection
Further refactors RecentTransactionsSection to separate remaining logic. Creates additional hooks and utility files as needed.
This commit is contained in:
29
src/utils/currencyFormatter.ts
Normal file
29
src/utils/currencyFormatter.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
/**
|
||||
* 숫자를 한국 통화 형식으로 변환합니다.
|
||||
* 1000 -> 1,000원
|
||||
*/
|
||||
export const formatCurrency = (amount: number): string => {
|
||||
return amount.toLocaleString('ko-KR') + '원';
|
||||
};
|
||||
|
||||
/**
|
||||
* 문자열에서 숫자만 추출합니다.
|
||||
* "1,000원" -> 1000
|
||||
*/
|
||||
export const extractNumber = (value: string): number => {
|
||||
const numericValue = value.replace(/[^\d]/g, '');
|
||||
return numericValue ? parseInt(numericValue, 10) : 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* 입력값을 통화 형식으로 변환합니다. (입력 필드용)
|
||||
* 1000 -> "1,000"
|
||||
*/
|
||||
export const formatInputCurrency = (value: string): string => {
|
||||
const numericValue = value.replace(/[^\d]/g, '');
|
||||
if (!numericValue) return '';
|
||||
|
||||
const number = parseInt(numericValue, 10);
|
||||
return number.toLocaleString('ko-KR');
|
||||
};
|
||||
Reference in New Issue
Block a user