'use client';

import { WithdrawalManagement } from '@/components/accounting/WithdrawalManagement';
import WithdrawalDetailClientV2 from '@/components/accounting/WithdrawalManagement/WithdrawalDetailClientV2';
import { getWithdrawals } from '@/components/accounting/WithdrawalManagement/actions';
import { ListPageSkeleton } from '@/components/ui/skeleton';
import { useAccountingListPage } from '@/hooks';

export default function WithdrawalsPage() {
  const { data, pagination, isLoading, mode } = useAccountingListPage(
    () => getWithdrawals({ perPage: 100 })
  );

  if (mode === 'new') return <WithdrawalDetailClientV2 initialMode="create" />;
  if (isLoading) return <ListPageSkeleton showStats statsCount={4} tableColumns={7} />;

  return (
    <WithdrawalManagement
      initialData={data}
      initialPagination={pagination}
    />
  );
}