import { StepHeader } from '@/components/onboarding/step-header'; import { ImportTransactionsDrawer } from '@/components/transactions/import-transactions-drawer'; import { Button } from '@/components/ui/button'; import { CreatedAccount } from '@/hooks/use-onboarding-state'; import { type Account, type Bank } from '@/types/account'; import { type AutomationRule } from '@/types/automation-rule'; import { type Category } from '@/types/category'; import { __ } from '@/utils/i18n'; import { usePage } from '@inertiajs/react'; import { ArrowRight, FileSpreadsheet, Upload } from 'lucide-react'; import { useEffect, useMemo, useState } from 'react'; interface StepImportTransactionsProps { account: CreatedAccount | undefined; onComplete: () => void; } export function StepImportTransactions({ account, onComplete, }: StepImportTransactionsProps) { const [isDrawerOpen, setIsDrawerOpen] = useState(false); const [hasImported, setHasImported] = useState(false); const { accounts, categories, banks, automationRules } = usePage<{ accounts: Account[]; categories: Category[]; banks: Bank[]; automationRules: AutomationRule[]; }>().props; const handleDrawerClose = (open: boolean) => { setIsDrawerOpen(open); if (!open) { setHasImported(true); } }; useEffect(() => { if (hasImported) { onComplete(); } }, [hasImported, onComplete]); const description = useMemo(() => { return account ? __( "Import transactions for your account. You can export transaction history from your bank's website.", ) : __( 'Import your transaction history to start tracking your finances.', ); }, [account]); return (
{__('Supported formats')}
{__('CSV, XLS, XLSX files')}