import { createFileRoute } from '@tanstack/react-router';
import { z } from 'zod';
import { CheckoutPage } from '@/features/checkout';

const checkoutSearchSchema = z.object({
  planId: z.string().uuid().optional(),
  txId: z.string().optional(),
  commandSize: z.coerce.number().optional(),
  commandQty: z.coerce.number().int().min(1).max(100).optional(),
  // Pay-first team-seat: the NON-secret descriptor (invitee/role/price/currency).
  // The Stripe clientSecret is created on the Pay click and kept in state — never
  // in the URL.
  seatEmail: z.string().optional(),
  seatRole: z.string().optional(),
  seatAmount: z.coerce.number().optional(),
  seatCurrency: z.string().optional(),
});

export const Route = createFileRoute('/_authenticated/dashboard/checkout')({
  validateSearch: checkoutSearchSchema,
  component: CheckoutPage,
});
