
import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import { authOptions } from '@/lib/auth';
import { NewLeadForm } from '@/components/leads/new-lead-form';
import { motion } from 'framer-motion';

export const dynamic = 'force-dynamic';

export default async function NewLeadPage() {
  const session = await getServerSession(authOptions);

  if (!session) {
    redirect('/auth/signin');
  }

  // Only allow admin and sales
  if (session.user.role === 'CUSTOMER') {
    redirect('/customer/dashboard');
  }

  return (
    <div className="container mx-auto py-8 space-y-6">
      <div>
        <h1 className="text-3xl font-bold gradient-text">Create New Lead</h1>
        <p className="text-muted-foreground mt-1">
          Add a new lead to your pipeline and start the conversion process
        </p>
      </div>

      <NewLeadForm />
    </div>
  );
}
