
import { useState } from 'react';
import { Transaction } from '@/contexts/budget/types';

/**
 * 최근 거래내역의 다이얼로그 상태를 관리하는 커스텀 훅
 */
export const useRecentTransactionsDialog = () => {
  const [selectedTransaction, setSelectedTransaction] = useState<Transaction | null>(null);
  const [isDialogOpen, setIsDialogOpen] = useState(false);

  const handleTransactionClick = (transaction: Transaction) => {
    setSelectedTransaction(transaction);
    setIsDialogOpen(true);
  };

  const handleCloseDialog = () => {
    setIsDialogOpen(false);
    // 약간의 딜레이 후 선택된 트랜잭션 초기화 (애니메이션 완료 후)
    setTimeout(() => {
      setSelectedTransaction(null);
    }, 300);
  };

  return {
    selectedTransaction,
    isDialogOpen,
    handleTransactionClick,
    handleCloseDialog,
    setIsDialogOpen
  };
};
