import { AppShell } from '@/components/app/app-shell'
import { requireRoleRoute } from '@/lib/role-route'
import { loadContactPicker } from '@/lib/data/contacts'
import { CarrierWizard } from './carrier-wizard'

/**
 * Carrier Dispatch · New Trip — `/cd-new-trip`. Drag in the rate con, the
 * trip fills itself, then invite the carrier's people.
 */
export default async function CarrierNewTripPage() {
  const { user, profile } = await requireRoleRoute('carrier')
  const contacts = await loadContactPicker(user.id)
  return (
    <AppShell profile={profile}>
      <main className="mx-auto max-w-2xl px-4 py-8">
        <h1 className="text-2xl font-bold tracking-tight">Create a trip</h1>
        <p className="mt-1 text-sm text-neutral-600">
          Drag in the rate con — we read it and fill the trip. Then invite your people.
        </p>
        <CarrierWizard contacts={{ drivers: contacts.drivers, brokers: contacts.brokers }} />
      </main>
    </AppShell>
  )
}
