'use client';

import dynamic from 'next/dynamic';
import type { SignatureFieldData } from '@/lib/db/schema';

// Dynamically import to disable SSR — react-pdf requires browser APIs (canvas, worker)
const SigningPageClient = dynamic(
  () => import('./SigningPageClient').then((m) => m.SigningPageClient),
  {
    ssr: false,
    loading: () => (
      <div
        style={{
          minHeight: '100vh',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          backgroundColor: '#FAF9F7',
          fontFamily: 'Georgia, serif',
          color: '#555',
        }}
      >
        Loading document...
      </div>
    ),
  }
);

interface SigningPageClientWrapperProps {
  token: string;
  documentName: string;
  signatureFields: SignatureFieldData[];
}

export function SigningPageClientWrapper({
  token,
  documentName,
  signatureFields,
}: SigningPageClientWrapperProps) {
  return (
    <SigningPageClient
      token={token}
      documentName={documentName}
      signatureFields={signatureFields}
    />
  );
}
