import { redirect } from 'next/navigation';
import { getSession } from '@/lib/auth';
import { handleGetSalesReturns } from '@/lib/actions/sales-return.actions';
import SalesReturnsList from '@/components/admin/sales/sales-returns-list';

export const metadata = { title: 'Sales Returns List | Sales' };

export default async function SalesReturnsListPage() {
  const session = await getSession();
  if (!session?.user) {
    redirect('/login');
  }

  const returnsResult = await handleGetSalesReturns();
  const salesReturns = returnsResult.success ? returnsResult.data || [] : [];

  return (
    <div className="space-y-4">
      <div>
        <h1 className="text-3xl font-bold">قائمة فواتير مردود المبيعات</h1>
      </div>
      <SalesReturnsList salesReturns={salesReturns} />
    </div>
  );
}
