import type { IToken } from '@model/other'
import type { ICart, IOrderCart, IShareWithUs } from '@src/model/Products'
import type { IAccount, ICatGrp, ICircuit, IImgGallery, IMovement, IMyCircuit } from '@model/GlobalStore';
import { IGallery } from '@model/GlobalStore'
import type { IBookedEvent } from './Calendar'

const enum ESexType {
  None = 0,
  Male = 1,
  Female = 2,
}

export interface IFriends {
  username: string
  date?: Date
}
export interface IGroupShort {
  groupname: string
  date?: Date
}

export interface IUserAdmins {
  username: string
  perm?: number
  date?: Date
}

export interface IMyGroup {
  _id: string
  groupname: string
  title?: string
  descr?: string
  photos: IImgGallery[]
  visibility?: number[]
  date_created?: Date
  date_updated?: Date
  admins?: IFriends[]
  req_users?: IFriends[]
  blocked?: boolean
  website?: string
  note?: string
  link_telegram?: string
  username_who_block?: string
  date_blocked?: Date
  createdBy?: string
  mycircuits?: ICircuit[]

  lastdate_reqRisGroup?: Date
  account?: IAccount
  recCatGrp?: ICatGrp
}

export interface ICalcStat {
  numUsersReg: number
  numByTab: object
}

export interface IUserNotifType {
  _id: number
  dir: number
  value: number
}

export interface IBookmark {
  id: string
  tab: number
}

export interface IFavorite {
  id: string
  tab: number
}
export interface ISeen {
  id: string
  tab: number
}

export interface IAttend {
  id: string
  tab: number
  num: number
}
export interface IReaction {
  id: string
  idrec: string
  username: string
  tab: number
  seen?: boolean
  fav?: boolean
  book?: boolean
  attend?: boolean
}

export interface IFavBook {
  username: string
}

export interface IUserProfile {
  img?: string
  nationality?: string
  intcode_cell?: string
  iso2_cell?: string
  cell?: string
  country_pay?: string
  email_paypal?: string
  payeer_id?: string
  advcash_id?: string
  revolut?: string
  link_payment?: string
  note_payment?: string
  username_telegram?: string
  firstname_telegram?: string
  lastname_telegram?: string
  website?: string
  teleg_id?: number
  teleg_id_old?: number
  teleg_checkcode?: number
  paymenttypes?: IPaymentType[]
  manage_telegram?: boolean
  admin_telegram?: boolean
  resplist?: any
  workerslist?: any
  dateofbirth?: Date | null
  born_city_id?: number
  born_city?: string
  born_province?: string
  resid_prov_id?: number
  resid_province: string
  resid_card: string
  born_country?: string
  my_dream?: string
  saw_and_accepted?: boolean
  saw_zoom_presentation?: boolean
  ask_zoom_partecipato?: boolean
  qualifica?: string
  qualified?: boolean
  qualified_2invitati?: boolean
  special_req?: boolean
  sex?: ESexType
  biografia?: string
  note?: string
  da_contattare?: boolean
  socio?: boolean
  socioresidente?: boolean
  consiglio?: boolean
  myshares: IShareWithUs[]
  friends: IFriends[]
  req_friends: IFriends[]
  handshake: IFriends[]
  mygroups: IMyGroup[]
  mycircuits: IMyCircuit[]
  last_circuitpath: string
  lastdate_reqRis?: Date
  lastdate_LinkReg?: Date
  userstoverify: IFriends[]
  manage_mygroups: IMyGroup[]
  notifs: IUserNotifType[]
  notif_idCities: number[]
  notif_provinces: string[]
  notif_regions: string[]
  notif_sectors: number[]
  notif_sector_goods: number[]
  stepTutorial: number
  noNameSurname: boolean
  noCircuit: boolean
  noCircIta: boolean
  noFoto: boolean
  reaction: IReaction[]
  // bookmark: IBookmark[]
  // favorite: IFavorite[]
  // seen: ISeen[]
  // attend: IAttend[]

  version?: number

  // Query
  myreaction: IReaction[]
  mybookings: IBookedEvent[]

  // in memory
  asked_friends: any[]
  asked_groups: IGroupShort[]
  refused_groups: IGroupShort[]
  list_usersgroup?: IFriends[]

  asked_circuits: any[]
  refused_circuits: any[]
  manage_mycircuits: ICircuit[]
  useraccounts: IAccount[]
  last_my_transactions: IMovement[]
  calc: ICalc
}

export interface ICalc {
  numGoodsAndServices?: number
}

export interface IPaymentType {
  key: string
  label: string
}

export interface IUserAport {
  username: string
  profile?: IUserProfile
}

export interface IUserShort {
  _id: string
  username: string
  name: string
  surname: string
  profile?: IUserProfile
}

export interface IUserFields {
  _id: string
  idapp?: string
  ind_order?: number
  email?: string
  username: string
  name: string
  surname: string
  password?: string
  ipaddr?: string
  perm?: number
  verified_email?: boolean
  verified_by_aportador?: boolean
  idMyGroup?: string
  reported?: boolean
  username_who_report?: string
  date_report?: Date
  notask_verif?: boolean
  trust_modified?: Date
  aportador_solidario?: string
  useraport?: IUserAport

  made_gift?: boolean
  tokens?: IToken[]
  date_reg?: Date
  lasttimeonline?: Date
  profile: IUserProfile
  qualified?: boolean
  numNaviEntrato?: number
  numinvitati?: number
  numinvitatiattivi?: number
  cart?: ICart
  orderscart?: IOrderCart
  calcstat?: ICalcStat | null

  account?: IAccount
}

export interface IUserExport {
  _id: string
  email?: string
  username: string
  username_telegram: string
  firstname_telegram: string
  lastname_telegram: string
}
/*
password?: string
 lang
 */

export interface IPerm {
  _id: number
  label: string
}

export interface IUserState {
  my: IUserFields
  lang: string
  repeatPassword?: string

  categorySel?: string

  tokenforgot?: string

  servercode?: number
  msg?: string
  resStatus?: number
  x_auth_token: string
  isLogged?: boolean
  isAdmin?: boolean
  isManager?: boolean
  isDepartment?: boolean
  isFacilitatore?: boolean
  isZoomeri?: boolean
  isTratuttrici?: boolean
  isEditor?: boolean
  isGrafico?: boolean
  isCommerciale?: boolean
  isTeacher?: boolean
  usersList?: IUserFields[]
  countusers?: number
  lastparamquery?: any
  updateTables?: boolean

  lista_editori?: IUserShort[] | null
}
