export type ExamStatus = "published" | "draft" | "cancelled" | string;

export type FieldType = "text" | "date" | "select";

export interface FormField {
  name: string;
  label: string;
  type: FieldType;
  required?: boolean;
  options?: string[];
}

export interface User {
  id: number;
  email: string;
  name: string;
  surname: string;
  displayName: string;
}

export interface ExamType {
  id: number;
  slug: string;
  organization_id: number;
  image_path?: string;
  title: string;
  description?: string;
  location?: string;
  date?: string;
  capacity?: number;
  availability?: number;
  price: number;
  status: ExamStatus;
  is_online?: number;
  booking_slots: BookingSlot[];
  form_schema: FormField[];
}

export interface BookingSlot {
  id: number;
  start_time: string;
  end_time: string;
  capacity: number;
  availability: number;
  exam_location_id?: number | null;
  is_online: number;
  location: {
    id: number;
    name: string;
  };
}

export interface Exam {
  id: number;
  title: string;
  description: string;
  booking_slots?: BookingSlot[];
}

export interface Booking {
  id?: number;
  reference?: string;
  status?: string;
  exam?: Exam;
  booking_slot?: BookingSlot;
  booking_slot_id?: number;
  user?: User;
  language?: string;
  locale?: string;
  change_request?: {
    id: number;
    status: string;
    created_at: string;
    type: string;
  };
}

export interface BookingResponse {
  data: { booking: Booking; stripe_payment: StripePayment };
  message: string;
  status: string;
}

export interface ChangeRequestResponse {
  message: string;
}

export interface ChangeRequestBody {
  booking_id?: number | null;
  language?: string;
  reason?: string;
  booking_slot_id?: number | null;
  locale?: string;
}

export interface UseBookingResult {
  booking: Booking | null;
  stripePayment: StripePayment | null;
  loading: boolean;
  error: string | null;
  refetch: () => Promise<void>;
}

export interface useChangeRequestResult {
  loading: boolean;
  error: string | null;
  changeRequest: (data: ChangeRequestBody) => Promise<void>;
}

export interface PaginationMeta {
  current_page: number;
  last_page: number;
}

export interface BodyCheckout {
  amount: number;
  currency?: string;
  custom_data: JSON | null;
  booking_slot_id: number | null;
  language: string;
  locale: string;
  exam_id: number;
}

export interface CheckoutResponse {
  data: { client_secret: string; booking: Booking };
  message: string;
  status: string;
}

export interface useCheckoutResult {
  clientSecret: string | null;
  isCartEmpty: boolean;
  loading: boolean;
  error: string | null;
  fetchCheckout: (amount: number, currency: string) => Promise<void>;
}

export interface useConfirmationResult {
  booking: Booking | null;
  stripePayment: StripePayment | null;
  loading: boolean;
  error: string | null;
  refetch: () => Promise<void>;
}

export interface StripePayment {
  id: number;
  amount: number;
  currency: string;
  status: string;
  payment_method: string;
  paymentMethod: string;
  metadata: Record<string, string>;
  created: number;
}

export interface RowDataType {
    [key: string]: string;
    firstName: string;
    lastName: string;
    company: string;
    phone: string;
    email: string;
}

export interface ErrorType {
    rowId: number;
    colId: string;
    msg: string;
};
