import { Recipient } from "./recipient";
import { Shipment } from "./shipment";

export type OrderDestinationType = "HOME" | "STORE" | "SERVICE_POINT" | "LOCKER";

export type OrderStateType =
  | "PENDING"
  | "CONFIRMED"
  | "SENT"
  | "IN_TRANSIT"
  | "READY_FOR_PICKUP"
  | "DELIVERED"
  | "CANCELLED";

export interface OrderListItem {
  reference: string;
  purchase_number: number;
  email: string;
  phone: string | null;
  option_name: string;
  carrier: string;
  destination_type: OrderDestinationType;
  name: string;
  recipient: {
    given_name: string;
    family_name: string;
    company_name: string;
  } | null;
  tracking_number: string;
  state: OrderStateType;
}

export interface OrderDetail {
  reference: string;
  purchase_number: number;
  email: string;
  phone: string | null;
  destination_type: OrderDestinationType;
  state: OrderStateType;
  channel: string;
  destination_reference?: string;
  name: string;
  care_of: string;
  street_address: string;
  street_address2: string;
  postal_code: string;
  city: string;
  country_code: string;
  region: string;
  items: OrderItem[];
  shipment: Shipment | null;
  recipient: Recipient | null;
}

export interface OrderItem {
  code: string;
  name: string | null;
  quantity: number;
}

export type ReturnOrigin = "WAREHOUSE" | "STORE";

export interface ReturnItemProspect {
  title?: string;
  code: string;
  quantity: number;
  gtin?: string;
}

export interface ReturnOrderProspect {
  order_reference: string;
  items: ReturnItemProspect[];
}

export interface ReturnProspects {
  return_origins: ReturnOrigin[];
  return_codes: Record<string, string>;
  return_order_prospects: ReturnOrderProspect[];
}

export interface ReturnItemIntent {
  code: string;
  quantity: number;
  return_code: string;
}

export interface ReturnOrderIntent {
  order_reference: string;
  items: ReturnItemIntent[];
}

export interface ReturnIntent {
  origin: ReturnOrigin;
  return_orders: ReturnOrderIntent[];
}
