import type { EState } from './Calendar'
import { shared_consts } from '@src/common/shared_vuejs'

export interface IMessagePage {
  show: boolean
  msg: IMessage
  state: EState
}

export interface ISource {
  page?: string
  event_id?: string
  infoevent?: string
}

export interface IIdentity {
  idapp?: string
  username?: string
}

export const enum StatusMessage {
  None = 0,
  WaitingToSend = 1,
  Sending = 2,
  Sent = 3,
  Received = 4,
  Readit = 5,
}

export const MsgDefault: IMessage = {
  _id: '',
  idapp: '',
  source: {
    event_id: '',
    infoevent: '',
    page: '',
  },
  origin: '',
  dest: '',
  message: '',
  datemsg: new Date(),
  read: false,
  deleted: false,
  status: StatusMessage.None,
}

export const NotifDefault: INotif = {
  _id: '',
  idapp: '',
  typedir: 0,
  typeid: 0,
  sender: '',
  dest: '',
  title: '',
  descr: '',
  datenotif: new Date(),
  read: false,
  deleted: false,
  status: StatusMessage.None,
  extrafield: '',
  extrarec: '',
}

export interface IMessage {
  _id?: any
  idapp?: string
  source?: ISource
  origin: string
  dest: string
  message: string
  datemsg?: Date
  read?: boolean
  deleted?: boolean
  status?: StatusMessage
  typesend?: number
}

export interface INotif {
  _id?: any
  idapp?: string
  typedir: number
  typeid: number
  sender: string,
  myimgsender?: string,
  dest: string,
  title: string
  descr: string
  datenotif?: Date
  status?: number
  openUrl?: string
  read?: boolean
  tablerec?: string
  idrec?: string
  deleted?: boolean
  extrafield?: string
  extrarec?: any
}

export interface IChat {
  username: string
  lasttimeActive?: Date
}

export interface IMsgUsers {
  username: string
  msgs: IMessage[]
  lastdataread?: Date
}

export interface IMessageState {
  last_msgs: IMessage[]
  users_msg: IMsgUsers[]
}

export interface INotifState {
  last_notifs: INotif[]
  last_notifcoins: INotif[]
  show_all: boolean
  updateNotification: boolean
  countNotif: number
}
