// تایپ‌های مربوط به سفارشات

export type OrderType = {
  _id: string;
  orderNumber: string;
  customer: {
    name: string;
  };
  seller?: {
    name: string;
  };
  amount: number;
  status: "Completed" | "Cancelled" | "Pending" | string;
  date: string;
  cancellationReason?: string;
  cancelledDate?: string;
};

export type PaymentType = {
  _id: string;
  transaction_id: string | null;
  payment_method: PaymentMethodType;
  priceDetails: PriceDetailsType;
  totalPrice: number;
  paymentStatus: string;
  createdAt: string;
};

export type PaymentMethodType = {
  _id: string;
  title_fa: string;
  title_en: string;
  description: string;
  provider: string;
  isActive: boolean;
  type: string;
};

export type PriceDetailsType = {
  shipping_cost: number;
  process_cost: number;
  total_retail_price: number;
  total_payable_price: number;
  total_discount: number;
  coupon_discount: number;
};

export type OrderItemsType = {
  _id: string;
  order_id: number;
  shop: ShopType;
  shipmentItems: ShipmentItemType[];
  shipper: ShipperType;
  trackCode: string | null;
  itemsCount: number;
  totalPaymentPrice: number;
  totalRetailPrice: number;
  totalSellingPrice: number;
  totalShipmentCost: number;
  postingDate: string | null;
  postingReceipt: string | null;
  status: string;
};

export type ShipmentItemType = {
  _id: string;
  product: ProductType;
  variant: VariantType;
  quantity: number;
  cancelled_quantity: number;
  returned_quantity: number;
  selling_price: number;
  retail_price: number;
  discount_percent: number;
  shipmentCost: number;
};

export type ProductType = {
  _id: number;
  title_fa: string;
  title_en: string;
  seoTitle: string | null;
  seoDescription: string | null;
  source: string;
  description: string;
  metaDescription: string;
  tags: string[];
  advantages: string[];
  disAdvantages: string[];
  imagesUrl: ImagesUrlType;
  isFake: string;
  voice: string | null;
  specifications: SpecificationType[];
  brand: BrandType;
  category: CategoryType;
  variants: string[];
};

export type ImagesUrlType = {
  cover: string;
  list: string[];
};

export type SpecificationType = {
  title: string;
  values: string[];
};

export type BrandType = {
  _id: string;
};

export type CategoryType = {
  _id: string;
};

export type VariantType = {
  _id: string;
  market_status: string;
  price: PriceType;
  stock: number;
  postingTime: number;
  isFreeShip: boolean;
  isWholeSale: boolean;
  shop: ShopType;
  saleFormat: SaleFormatType;
  warranty: number;
  size?: number;
  meterage?: number;
};

export type PriceType = {
  order_limit: number;
  retailPrice: number;
  selling_price: number;
  is_specialSale: boolean;
  discount_percent: number;
  specialSale_order_limit: number | null;
  specialSale_quantity: number | null;
  specialSale_endDate: string | null;
};

export type SaleFormatType = {
  wholeSale: unknown[];
};

export type ShopType = {
  _id: string;
};

export type ShipperType = {
  _id: number;
  name: string;
  description: string;
  deliveryTime: number;
  deliveryType: string;
};

export type ShipmentAddressType = {
  address: string;
  city: string;
  province: string;
  plaque: string;
  postalCode: string;
  phone: string;
};

export type CancellationCategoryType = {
  _id: string;
  title: string;
  description: string;
  status: string;
  deleted: boolean;
};

export type ReturnCategoryType = {
  _id: string;
  title: string;
  description: string;
  status: string;
  deleted: boolean;
};

// تایپ‌های صفحه‌بندی
export type PagerType = {
  page: number;
  limit: number;
  totalItems: number;
  totalPages: number;
  prevPage: boolean | null;
  nextPage: string | null;
};

export type OrdersResponseType = {
  status: number;
  success: boolean;
  results: {
    orders: OrderType[];
    pager: PagerType;
  };
};

export type CategoriesResponseType = {
  status: number;
  success: boolean;
  results: {
    categories: CancellationCategoryType[] | ReturnCategoryType[];
    pager: PagerType;
  };
};

export type CreateCategoryType = {
  title: string;
  description: string;
};

// تایپ‌های مربوط به سفارشات بومی
export type PriceRangeType = {
  minPrice: number;
  maxPrice: number;
};

export type UserType = {
  fullName: string;
};

export type NativeOrderType = {
  _id: number;
  user: UserType;
  payment: PaymentType;
  orderItems: OrderItemsType;
  shipmentAddress: ShipmentAddressType;
  orderStatus: string;
  createdAt: string;
};

export type NativeOrdersResponseType = {
  status: number;
  success: boolean;
  results: {
    pager: PagerType;
    orders: NativeOrderType[];
    priceRange: PriceRangeType;
  };
};
