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

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

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

  return (
    <PageContainer
      pageTitle='Customer Detail'
      pageDescription='Overview, contacts, shared contacts, enquiries, quotations, and activity log'
    >
      <HydrationBoundary state={dehydrate(queryClient)}>
        <CustomerDetailPage id={id} />
      </HydrationBoundary>
    </PageContainer>
  );
}
