import type { IResponse } from "@/types/response.types";

export type CreateProductType = {
  categoryId: string;
  title: string;
  desc: string;
  content: string[];
  weekDays: number[];
  mealTypes: string[];
  price: number;
  prepareTime: number;
  isActive: boolean;
  images: string[];
  inPlaceServe: boolean;
  pickupServe: boolean;
  discount: number;
  isSpecialOffer: boolean;
  dailyStock: number;
  order: number;
};

export type Category = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  title: string;
  isActive: boolean;
  restId: string;
  avatarUrl: string;
  order: number | null;
  parent?: Category;
};

export type ProductDetailsCategory = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  title: string;
  isActive: boolean;
  restaurant: string;
  avatarUrl: string | null;
};

export type Inventory = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  product?: string;
  food?: string; // API compatibility
  totalStock: number;
  availableStock: number;
};

export type Product = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  restaurant: string;
  category: ProductDetailsCategory;
  inventory: Inventory;
  title: string;
  desc: string;
  content: string[];
  price: number;
  order: number | null;
  prepareTime: number | null;
  weekDays: number[];
  mealTypes: string[];
  isActive: boolean;
  images: string[];
  inPlaceServe: boolean;
  pickupServe: boolean;
  score: number;
  discount: number;
  isSpecialOffer: boolean;
};

export type GetProductsParams = {
  page?: number;
  limit?: number;
  search?: string;
  orderBy?: string;
  order?: "asc" | "desc";
  categoryId?: string;
  isActive?: boolean;
};

export type ProductDetails = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  restaurant: string;
  category: ProductDetailsCategory;
  inventory: Inventory;
  title: string;
  desc: string;
  content: string[];
  price: number;
  order: number | null;
  prepareTime: number;
  weekDays: number[];
  mealTypes: string[];
  isActive: boolean;
  images: string[];
  inPlaceServe: boolean;
  pickupServe: boolean;
  score: number;
  discount: number;
  isSpecialOffer: boolean;
};

export type PaginationMeta = {
  total: number;
  page: string;
  limit: string;
  totalPages: number;
};

export type GetCategoriesResponseType = IResponse<Category[]>;
export type GetProductsResponseType = IResponse<Product[]> & { meta: PaginationMeta };
export type GetProductDetailsResponseType = IResponse<ProductDetails>;

export type CreateCategoryType = {
  title: string;
  isActive: boolean;
  avatarUrl: string;
  order: number;
  parentId?: string;
};

export type Icon = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  url: string;
  group: string;
};

export type IconGroup = {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  name: string;
  icons: Icon[];
};

export type GetIconsResponseType = IResponse<IconGroup[]>;
