'use client';

import { SalesManagement } from '@/components/accounting/SalesManagement';
import { SalesDetail } from '@/components/accounting/SalesManagement/SalesDetail';
import { getSales } from '@/components/accounting/SalesManagement/actions';
import { ListPageSkeleton } from '@/components/ui/skeleton';
import { useAccountingListPage } from '@/hooks';

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

  if (mode === 'new') return <SalesDetail mode="new" />;
  if (isLoading) return <ListPageSkeleton showStats statsCount={4} tableColumns={10} />;

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