// zero value may be considered an undefined ... donn't use in enums
import { ColumnType } from "antd/es/table";

export enum AlignType {
  "left" = "left",
  "center" = "center",
  "right" = "right",
}
export enum RowSelectionType {
  Radio = "radio",
  Checkbox = "checkbox",
}
export enum SortOrder {
  Descend = "descend",
  Ascend = "ascend",
}

export interface ProColumnType<T extends Record<string, any>>
  extends Omit<ColumnType<T>, "title" | "dataIndex"> {
  notSearchable?: boolean;
  title?: string;
  dataIndex: string;
  visible?: boolean;
  defaultVisible?: boolean;
  editable?: boolean;
  dataType?: CellDataTypes;
  rules?: any;
  width?: number;
  onCell?: (rec: T) => any;
  excelStyle?: any;
  fixed?: FixedType;
}

export enum CellDataTypes {
  TextCell = 1,
  NumberCell = 2,
  DateCell = 3,
  CheckboxCell = 4,
  SelectCell = 5,
  MonetaryCell = 6,
}

export interface ProEditableColumnType<T extends Record<string, any>>
  extends Omit<ColumnType<T>, "title" | "dataIndex"> {
  title: string;
  dataIndex: string;
  children?: Array<ProColumnType<T>>;
  visible?: boolean;
  defaultVisible?: boolean;
  editable?: boolean;
  dataType?: CellDataTypes;
  rules?: any;
  width?: number;
  onCell?: (rec: any) => any;
  inputValidations?: any;
  fixed?: FixedType;
}

export interface ProFullColumnType<T extends Record<string, any>>
  extends ProColumnType<T> {
  visible: boolean;
  defaultVisible: boolean;
}

// export interface ProEditableColumnType<T> extends ColumnType<T> {
//   title: string | { key: string; varKey: string };
//   children?: Array<ProColumnType<T>>;
//   visible?: boolean;
//   defaultVisible?: boolean;
//   editable?: boolean;
//   dataType?: CellDataTypes;
//   rules?: any;
//   width?: number;
//   onCell?: any;
//   inputValidations?: any;
// }

export interface ResizableColumnType<T> extends ColumnType<T> {
  width: number;
  onResize: (index: number) => void;
}

export enum UploadFileStatus {
  done = "done",
  success = "success",
  error = "error",
  uploading = "uploading",
  removed = "removed",
}

export type ProcessInfoType = {
  processId?: number;
  dataUrl?: string;
  saveDataUrl?: string;
  deleteDataUrl?: string;
  tableInfoUrl?: string;
  documentRout?: string; // used document "id" link
  moduleName?: string; //  used in the Title of the printed report
  totalColumns?: Array<string>;
  staticTableHeaders?: Array<ProFullColumnType<any>>;
  staticContentTableHeaders?: Array<ProFullColumnType<any>>;

  contentTableInfoUrl?: string;
  extraParams?: string;
  parseFunc?: (list: any) => any[];
  saveParse?: (list: any) => FormData;
  title?: string;

  filterColumns?: FilterIdentifier[];
  stopTotalsCalcBySlice?: boolean;
  stopParseBySlice?: boolean;
  filterColumnsInfo?: Array<FilterColumnInfo>;
  noDocDateFilter?: boolean;
  withImage?: boolean;
  isReport?: boolean;
  handleCardClick?: (entityId?: number) => void;
};

export enum FixedType {
  "left" = "left",
  "right" = "right",
}

export enum ResourceViewType {
  "Top" = 1,
  "Bottom" = 2,
  "Both" = 3,
}

export type LinkParameterType = {
  key: string;
  sign: "=" | ">" | ">=" | "<" | "<=";
  value: string;
};
 
export type LoginUserType = {
  username?: string;
  password?: string;
};

export enum Mode {
  Edit = 1,
  New = 2,
  View = 3,
  Delete = 4,
}

export type ProTabPaneProps = {
  key: string;
  dataIndex?: string;
  title: string;
  content?: React.ReactNode;
  disabled?: boolean;
};

export type TableHeaderType = {
  extrainfo?: string | number;
  width?: number;
  sorter?: any;
  rowid: number;
  key: number; // for table header automation
  id: number;
  tablename: string;
  index: string;
  title: string;
  order: number;
  visible: boolean;
  preset: string;
  defaultvisible: boolean;
};

export type FilterComponentProps = {
  filterIdentifier: FilterIdentifier; // unique identifier for all filters
};

export type ActiveFilterType = {
  filterIdentifier: FilterIdentifier; // unique identifier for all filters
  filterField?: FilterColumn;
  filterTitle: string;
  filterValue: any;
  filterDefaultValue?: any;
  filterValueTitle: string;
  filterRequired?: boolean;
  filterExtra?: any;
};

export type FilterColumn =
  | "filters[id][$eq]"
  | "name"
  | "documentid"
  | "documentnumber"
  | "page"
  | "filters[is_fully_paid][$eq]"
  | "filters[customer][first_name][$contains]"
  | "filters[print_times][$gte]"
  | "location_id"
  | "documentdate"
  | "filters[printed_at][$null]"
  | "per_page"
  | "filters[printed_at][$eq]"
  | "created_at"
  | "warehouse_id"
  | "filters[send_datetime][$eq]"
  | "warehouse_id"
  | "account_id"
  | "customer_id"
  | "currency_id"
  | "conversion_method"
  | "financeAccountId"
  | "printed_at"
  | "filters[customer][id][$eq]"
  | "filters['printed_at'][$between][0]"
  | "supplier_id";

export type FilterIdentifier =
  | "DatePicker"
  | "DateRange"
  | "DocId"
  | "DocStatus"
  | "Page"
  | "PageSize"
  | "ShowDebitInvoice"
  | "CustomerName"
  | "PrintTimes"
  | "IsFinanciallyCompleted"
  | "Floor"
  | "Warehouse"

  /*
   ** Note: if you need to send some extra default vale without showing an input add its Identifier here
   ** (add the word "Fake" at the end)
   */
  | "ResourceTypeFake"
  | "ActiveFake"
  | "ModuleFake";

export type FilterColumnInfo = {
  filterIdentifier: FilterIdentifier; // unique identifier for all filters
  dataIndex?: FilterColumn;
  defaultValue?: any;
  required?: boolean;
  title?: string;
  valueTitle?: string;
  extra?: any;
};

export interface ResponseType {
  status: number;
  data: Data;
}

export interface Data {
  message: string;
}

export type ImageType = {
  collection_name: string;
  name: string;
  file_name: string;
  mime_type: string;
  size: number;
  url: string;
};

export enum TableStatus {
  available = "AVAILABLE",
  busy = "BUSY",
  requestPayment = "PENDING_INVOICE",
}

export interface RegisterType {
  id: number;
  opening_balance: number;
  total_income: number;
  total_expenses: number;
  closing_balance: number;
  grand_total: number;
  total_cashier_income: number;
}

export interface SessionPayload {
  closing_balance?: number;
  total_expenses?: number;
}

export enum Roles {
  SuperUser = "super-admin",
  Admin = "admin",
  Cashier = "cashier",
  Manager = "manager",
  TaxAccount = "tax-account",
}

export interface District {
  id: number;
  name: string;
  area: Area;
}

export interface Area {
  id: number;
  name: string;
  province: Province;
}

export interface Province {
  id: number;
  name: string;
}

export interface Translation {
  name: string;
  locale: string;
}

// #################################################

export interface CartItem {
  id: number | string;
  name: string;
  price: number;
  image: string;
  quantity: number;
  description: string;
  variant?: string;
  extras?: string[];
  extrasgroup?: string[];
  isHasLoyalty?: boolean;
  no_of_stamps_give?: number;
}

export interface User {
  id: string;
  email: string;
  name: string;
  role: "admin" | "user";
}

export type Locale = "en" | "ar";
export type Theme = "light" | "dark";

export interface ApiResponse {
  success: boolean;
  result: any;
  message: string;
  error: any;
}

export interface Restaurant {
  id: string;
  name: string;
  nameAR: string;
  address: string;
  addressAR: string;
  description: string;
  descriptionAR: string;
  lat: string;
  lng: string;
  logo: string;
  cover: string;
  icon: string;
  phone: string;
  subdomain: string;
  menu_url: string;
  map_url: string;
  instagram: string;
  primary_color: string;
  package_id: number;
  price_rate: number;
  vat: number;
  delivery_fees: string;
  global_currency: string;
  local_currency: string;
  hasDinein: boolean;
  dineIn: boolean;
  viewMenuOnly: boolean;
  pickup: boolean;
  delivery: boolean;
  gift: boolean;
  toOffice: boolean;
  toRoom: boolean;
  online_payment: number;
  cash_payment: number;
  isCashPaymentEnabled: boolean;
  is_wallet_payment_enabled: number;
  is_booking_enabled: number;
  is_loyalty_enabled: number;
  loyalty_stamps: any;
  loyalty_stamp_image: string;
  is_call_waiter_enabled: number;
  is_hotel: number;
  is_schedule_order_enabled: number;
  pickup_type: string;
  use_googlemaps_url: number;
  view_webmenu_only: number;
  enable_apple_passkey: number;
  menu_background: string;
  taxes: any[];
  hours: Hours;
  logom?: string;
  coverm?: string;
}

export interface Hours {
  id: number;
  created_at: string;
  updated_at: string;
  "0_from": string;
  "0_to": string;
  "1_from": string;
  "1_to": string;
  "2_from": string;
  "2_to": string;
  "3_from": string;
  "3_to": string;
  "4_from": string;
  "4_to": string;
  "5_from": string;
  "5_to": string;
  "6_from": string;
  "6_to": string;
  restorant_id: number;
  "2_0_from": any;
  "2_0_to": any;
  "2_1_from": any;
  "2_1_to": any;
  "2_2_from": any;
  "2_2_to": any;
  "2_3_from": any;
  "2_3_to": any;
  "2_4_from": any;
  "2_4_to": any;
  "2_5_from": any;
  "2_5_to": any;
  "2_6_from": any;
  "2_6_to": any;
}

export interface RestaurantDetails {
  restautantId: string;
  restautantName: string;
  nameAR: string;
  address: string;
  addressAR: string;
  restautantImage: string;
  restaurant_logo: string;
  restaurant_cover: string;
  distance: number;
  description: string;
  descriptionAR: string;
  price_rate: number;
  vat: number;
  lat: string;
  lng: string;
  hasDinein: boolean;
  dineIn: boolean;
  viewMenuOnly: boolean;
  pickup: boolean;
  delivery: boolean;
  gift: boolean;
  toOffice: boolean;
  toRoom: boolean;
  online_payment: number;
  online_payment_for: number;
  is_wallet_payment_enabled: number;
  is_booking_enabled: number;
  loyalty_stamp_image: string;
  loyalty_stamps: number;
  customer_loyalty_points: number;
  is_loyalty_enabled: number;
  package_id: number;
  deliver_to_office: number;
  delivery_fees: string;
  delivery_to_office_fees: string;
  isCashPaymentEnabled: boolean;
  banner: Banner[];
  contact_number: string;
  menu_url: string;
  taxes: Tax[];
  openingTime: string;
  closingTime: string;
  isOpened: boolean;
  isFav: boolean;
}

export interface Banner {
  restaurant_banner1: string;
  restaurant_banner2: string;
  restaurant_banner3: string;
}

export interface Tax {
  id: number;
  restorant_id: number;
  name: string;
  name_local: string;
  percentage: string;
  is_active: number;
  created_at: string;
  updated_at: string;
  deleted_at: any;
}

export interface Category {
  id: number;
  name: string;
  nameAR?: string;
  nameEN?: string;
  image?: string;
  description?: string;
  descriptionAR?: string;
  order?: number;
  is_active?: boolean;
  created_at?: string;
  updated_at?: string;
}

export interface Product {
  id: number;
  css_object_fit: string;
  isAvailableBasedOnTime: boolean;
  no_of_stamps_give: number;
  isHasLoyalty: boolean;
  name: string;
  nameOther: string;
  price: number;
  pricing_method: string;
  original_price: number;
  preperation_minutes: number;
  description: string;
  descriptionAR: string;
  image: string;
  imageNew: string;
  image_small: string;
  available: boolean;
  currency: string;
  variants: Variant[];
  extras: Extra2[];
  categoryId?: number; // to be sent
  isHasExtras: boolean;
  isHasVarint: boolean;
  isHasextraGroup: boolean;
  is_vat_disabled: number;
  ingredients?: string[];
  nutritionalInfo?: {
    calories: number;
    protein: number;
    carbs: number;
    fat: number;
  };
  variantsArray: VariantsArray[];
  theExtrasGroups: TheExtrasGroup[];
}

export interface Variant {
  id: number;
  price: number;
  available: string;
  options: Option[];
  optionsAR: Option[];
  extras: Extra[];
}

export interface Option {
  option: string;
  value: string;
}

export interface Extra {
  id: number;
  price: number;
  name: string;
}

export interface Extra2 {
  id: number;
  price: number;
  name: string;
}

export interface TheExtrasGroup {
  id: number;
  name: string;
  nameAR: string;
  label: string;
  labelAR: string;
  limit: number;
  item_id: number;
  created_at: string;
  updated_at: string;
  deleted_at: any;
  force_limit_selection: number;
  extras: Extra[];
}

export interface VariantsArray {
  id: number;
  price: number;
  options: string;
  image: string;
  qty: number;
  enable_qty: number;
  order: number;
  item_id: number;
  created_at: string;
  updated_at: string;
  deleted_at: any;
  available: string;
  extras: Extra3[];
  OptionsList: string;
}

export interface Extra3 {
  id: number;
  item_id: number;
  price: number;
  name: string;
  nameAR: string;
  created_at: string;
  updated_at: string;
  deleted_at: any;
  extra_for_all_variants: number;
  is_custome: number;
  is_available: number;
  modifier_id: any;
  pivot: Pivot;
}

export interface Pivot {
  variant_id: number;
  extra_id: number;
}

export interface NutritionalInfo {
  calories: number;
  protein: number;
  carbs: number;
  fat: number;
}
