Further refactors RecentTransactionsSection to separate remaining logic. Creates additional hooks and utility files as needed.
30 lines
784 B
TypeScript
30 lines
784 B
TypeScript
|
|
/**
|
|
* 숫자를 한국 통화 형식으로 변환합니다.
|
|
* 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');
|
|
};
|