
import React, { useState } from 'react';
import { useForm } from 'react-hook-form';
import { Form } from '@/components/ui/form';
import ExpenseFormFields from './ExpenseFormFields';
import ExpenseSubmitActions from './ExpenseSubmitActions';

export interface ExpenseFormValues {
  title: string;
  amount: string;
  category: string;
  paymentMethod: '신용카드' | '현금';
}

interface ExpenseFormProps {
  onSubmit: (data: ExpenseFormValues) => void;
  onCancel: () => void;
  isSubmitting?: boolean;
}

const ExpenseForm: React.FC<ExpenseFormProps> = ({ 
  onSubmit, 
  onCancel, 
  isSubmitting = false 
}) => {
  const form = useForm<ExpenseFormValues>({
    defaultValues: {
      title: '',
      amount: '',
      category: '음식',
      paymentMethod: '신용카드'
    }
  });
  
  return (
    <Form {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
        <ExpenseFormFields 
          form={form} 
          isSubmitting={isSubmitting} 
        />
        
        <ExpenseSubmitActions 
          onCancel={onCancel} 
          isSubmitting={isSubmitting} 
        />
      </form>
    </Form>
  );
};

export default ExpenseForm;
