Fix: Resolve variable hoisting issue

Move the formatWithCommas function definition before its usage to fix the TypeScript error TS2448.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 04:18:51 +00:00
parent c07a4c7295
commit 5e6bda76af

View File

@@ -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);