import { HydrationBoundary, dehydrate } from '@tanstack/react-query';
import PageContainer from '@/components/layout/page-container';
import { quotationByIdOptions } from '@/features/crm-demo/api/queries';
import { QuotationDetailPage } from '@/features/crm-demo/components/quotation-detail';
import { getQueryClient } from '@/lib/query-client';

type PageProps = { params: Promise<{ id: string }> };

export default async function QuotationDetailRoute({ params }: PageProps) {
  const { id } = await params;
  const queryClient = getQueryClient();
  void queryClient.prefetchQuery(quotationByIdOptions(id));

  return (
    <PageContainer
      pageTitle='Quotation Detail'
      pageDescription='Header, status, revision, customer roles, item table, approval timeline, and preview panel'
    >
      <HydrationBoundary state={dehydrate(queryClient)}>
        <QuotationDetailPage id={id} />
      </HydrationBoundary>
    </PageContainer>
  );
}
