/**
 * Checkout form types
 */

import { z } from "zod"

/**
 * Contact Information Schema
 */
export const ContactInformationSchema = z.object({
  email: z.string().email("Please enter a valid email address"),
  phone: z
    .string()
    .min(1, "Phone number is required")
    .regex(/^\(\d{3}\) \d{3}-\d{4}$/, "Please enter a valid 10-digit US phone number"),
})

export type ContactInformation = z.infer<typeof ContactInformationSchema>

/**
 * Billing Address Schema (reuse from lib/schemas.ts)
 */
export const BillingAddressSchema = z.object({
  first_name: z.string().min(1, "First name is required"),
  last_name: z.string().min(1, "Last name is required"),
  address_1: z.string().min(1, "Address is required"),
  address_2: z.string().optional(),
  city: z.string().min(1, "City is required"),
  state: z.string().min(1, "State is required"),
  postcode: z.string().min(1, "Postal code is required"),
  country: z.string().min(2, "Country is required").max(2),
})

export type BillingAddress = z.infer<typeof BillingAddressSchema>

/**
 * Shipping Address Schema (same as billing)
 */
export const ShippingAddressSchema = BillingAddressSchema

export type ShippingAddress = z.infer<typeof ShippingAddressSchema>

/**
 * Complete Checkout Form
 */
export interface CheckoutFormData {
  contact: ContactInformation
  billing: BillingAddress
  shipping: ShippingAddress | null // null if same as billing
  shippingSameAsBilling: boolean
}

/**
 * Payment States
 */
export type PaymentState = "idle" | "creating_intent" | "processing" | "succeeded" | "failed"

export interface PaymentError {
  code: string
  message: string
  details?: any
}







