import { ReviewItemData } from "./review";

export interface ProductItemModel {
  _id: string;
  name: string;
  slug: string;
  image: string;
  mobileImage: string;
  promotionalText: string | null;
  shortDescription: string;
  position: number;
  parentId: {
    slug: string | null;
  };
  bestSellers: boolean;
  newArrivals: boolean;
  popularProduct: boolean;
  price: string;
  quantity: string;
}

export interface ProductResponse {
  success: boolean;
  data: ProductItemModel[];
  pagination: {
    total: number;
    page: number;
    limit: number;
    totalPages: number;
  };
}

export interface ImagesData {
  _id: string;
  image: string;
  isDefault: true
  isDeleted: false
  detail: []
}

export interface CategoryData {
  _id: string;
  name: string;
  slug: string;
  image: string;
  banner: string;
  description: string;
  shortDescription: string;
  parentId: {
    _id: string;
    name: string;
    slug: string;
    image: string;
    banner: string;
    description: string;
    shortDescription: string;
  }
}

export interface IdeasModel {
  description: string;
  id: string;
  image: string;
  parentId: string;
  position: number;
  title: string;
  type: string;
}

export interface TemplateDetailModel {
  variantId: {
    _id: string;
    attributeInfo: string;
    attributeType: {
      _id: string;
      name: string;
      code: string;
      position: number;
    };
    isAfterShow: boolean;
    isRequired: boolean;
    isTemplate: boolean;
    parentId: string;
    position: number;
    status: boolean;
    type: string;
  };
  attributeItemId: {
    attributeTypeId: string;
    displayName: string;
    image: string;
    name: string;
    position: number;
    _id: string;
  };
  position: number;
  status: boolean;
}

export interface ProductTemplateModel {
  _id: string;
  name: string;
  parentId: string;
  options: TemplateDetailModel[];
  type: string;
  pdf: string;
  psd: string;
  ai: string;
  jpg: string;
  svg: string;
  position: number;
  height: string;
  width: string;
  bleedArea: string;
  trimArea: string;
  safetyArea: string;
}

export interface AttributeTypeModel {
  _id: string;
  name: string;
  code: string;
  position: number;
  attributeInfo?: string;
  type?: string;
}

export interface AttributeItemModel {
  _id: string;
  attributeTypeId: string;
  name: string;
  displayName: string;
  image: string;
  position: number;
}

export interface ProductOptionAttributeItem {
  // attributeItemDisplayName: string;
  // attributeItemId: string;
  // attributeItemImage: string;
  attributeItemName: string;
  // variantInfo: string;
  // variantIsAfterShow: boolean;
  // variantIsRequired: boolean;
  // variantIsTemplate: boolean;
  // variantName: string;
  // variantStatus: boolean;
  // variantType: string;
  // _id?: string;
  // attributeTypeId?: AttributeTypeModel | string;
  extraPrice?: number;
  isOutOfStock?: boolean;
  isRecommended?: boolean;
  isPopularItem?: boolean;
  variantCode: string;
  // variantId: string;
  variantItemId: {
    attributeItemId: {
      attributeTypeId: string,
      displayName: string,
      image: string,
      name: string,
      position: number;
      _id: string
    }
    position: number;
    status: boolean;
    variantId: {
      attributeInfo: string;
      attributeType: {
        _id: string,
        name: string,
        code: string,
        position: number
      },
      isAfterShow: boolean,
      isRequired: boolean,
      isTemplate: boolean,
      parentId: string,
      position: number,
      status: boolean,
      type: string,
      _id: string
    }
    _id: string;
  }
}

export interface ProductQuantityOptionModel {
  _id: string;
  quantity: number;
  unitPrice: number;
  price: number;
  totalPrice: number;
  markupPercent: number;
  markupPrice: number;
  discountPercent: number;
  percentage?: number;
  status: boolean;
}

export interface TurnaroundTimeModel {
  _id: string;
  name: string;
  estimatedCompletionNumbersDate: number;
  cutOffTime: string;
  estimatedDateNumber: number;
  position: number;
}

export interface ProductTurnaroundTimeModel {
  _id: string;
  min: number;
  max: number;
  turnaroundTimes: TurnaroundTimeModel[];
  turnaround?: TurnaroundTimeModel[];
  status: boolean;
}

export interface FinalQuantityModel {
  _id?: string;
  quantity: number;
  price: number;
  markBasePrice?: number;
  percentage?: number;
  unitPrice?: number;
  totalPrice?: number;
  withoutpercentageprice?: number;
  selected?: boolean;
}

export interface ProductOptionDetailItem {
  attribute?: {
    name?: string;
    attributeType?: {
      name?: string;
    };
  };
  attributeItem?: {
    name?: string;
    displayName?: string;
  };
  extraPrice?: number;
}

export interface ProductOptionDataModel {
  _id: string;
  name: string;
  parentId: string;
  weight: number;
  stock: number;
  options: ProductOptionAttributeItem[];
  quantityOptions: ProductQuantityOptionModel[];
  turnaroundOptions: ProductTurnaroundTimeModel[];
  detail?: ProductOptionDetailItem[];
  price?: number;
}

export type ProductOptionGroupModel = ProductOptionAttributeItem;
export type ProductSpecOptionDataModal = ProductOptionDataModel;

export interface ProductSpecItemModel {
  _id: string;
  specId: string;
  title: string;
  description: string;
  image: string;
  position: number;
  status: boolean;
}

export interface ProductSpecModel {
  _id: string;
  parentId: string;
  name: string;
  position: number;
  items?: ProductSpecItemModel[];
}

export interface ProductFaqModel {
  _id: string;
  categoryId?: string;
  question: string;
  answer: string;
  position: number;
  status: boolean;
  langCode?: string;
}


export interface ProductFaqCategoryModel {
  _id: string;
  name: string;
  parentId?: string;
  status: boolean;
  slug?: string;
  position: number;
  langCode?: string;
  items?: ProductFaqModel[];
  questions?: ProductFaqModel[];
}

export interface ProductVariantItemModel {
  _id: string;
  variantId?: string;
  attributeItemId: AttributeItemModel;
  status: boolean;
  position: number;
}

export interface ProductVariantModel {
  _id: string;
  attributeType: AttributeTypeModel;
  parentId: string;
  type: 'select' | 'dropdown' | 'radio' | 'color' | 'text' | 'checkbox' | string;
  attributeInfo?: string;
  status: boolean;
  isRequired: boolean;
  isTemplate: boolean;
  isAfterShow: boolean;
  position: number;
  items: ProductVariantItemModel[];
}

export interface VariantGroupItem {
  _id: string;
  displayName: string;
  name?: string;
  image?: string;
  position?: number;
  extraPrice?: number;
  outOfStock?: boolean;
  isRecommended?: boolean;
  popularItem?: boolean;
}

export interface VariantGroup {
  id: string;
  name: string;
  attributeInfo?: string;
  type?: string;
  position?: number;
  isAfterShow?: boolean;
  items: VariantGroupItem[];
}

export interface ProductBySlugResponse {
  success: boolean;
  data: {
    _id: string;
    category: CategoryData;
    variantGroups: VariantGroup[];
    images: ImagesData[];
    ideas: IdeasModel[];
    templates: ProductTemplateModel[];
    options: ProductOptionDataModel[];
    specs: ProductSpecModel[];
    faqs: ProductFaqModel[];
    reviews: ReviewItemData[];
  };
}


export interface IndustriesProductResponse {
  success: boolean;
  status?: boolean;
  data: ProductItemModel[];
  totalCount?: number;
  totalPages?: number;
}

export type ProductQuantityModel = ProductQuantityOptionModel;

export interface ProductOptionByIdResponse {
  success: boolean;
  data: ProductOptionDataModel;
}

export interface ProductQuantityResponse {
  success: boolean;
  status?: boolean;
  data: ProductQuantityOptionModel[];
}

export interface ProductTurnaroundTimeResponse {
  success: boolean;
  status?: boolean;
  data: ProductTurnaroundTimeModel[];
}

export type ProductOptionPriceResponse = any;
export type ProductOptionResponse = any;