Fix: Resolve variable hoisting issue
Move the formatWithCommas function definition before its usage to fix the TypeScript error TS2448.
This commit is contained in:
@@ -24,6 +24,12 @@ const formSchema = z.object({
|
||||
category: z.enum(['식비', '생활비', '교통비']),
|
||||
});
|
||||
|
||||
// Function to format number with commas
|
||||
const formatWithCommas = (value: string) => {
|
||||
const numericValue = value.replace(/[^0-9]/g, '');
|
||||
return numericValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
};
|
||||
|
||||
interface TransactionEditDialogProps {
|
||||
transaction: Transaction;
|
||||
open: boolean;
|
||||
@@ -60,12 +66,6 @@ const TransactionEditDialog: React.FC<TransactionEditDialogProps> = ({
|
||||
onOpenChange(false);
|
||||
};
|
||||
|
||||
// Function to format number with commas
|
||||
const formatWithCommas = (value: string) => {
|
||||
const numericValue = value.replace(/[^0-9]/g, '');
|
||||
return numericValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
};
|
||||
|
||||
const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const formattedValue = formatWithCommas(e.target.value);
|
||||
form.setValue('amount', formattedValue);
|
||||
|
||||
Reference in New Issue
Block a user