// import * as mongoose from 'mongoose'
// import * as moment from 'moment'
// import { Schema } from "mongoose";
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types, HydratedDocument } from 'mongoose';
import moment from 'moment';

export enum Account_status {
  ACTIVATED = 'ACTIVATED',
  DEACTIVATED = 'DEACTIVATED',
  PENDING = 'PENDING',
}
const type = [
  null,
  'USER',
  'ADMIN',
  'VENDOR',
  'STAFF',
];

export enum UserRole {
  null = null,
  USER = "USER",
  ADMIN = 'ADMIN',
  VENDOR = 'VENDOR',
  STAFF = 'STAFF'
}

export enum UserStatus {
  ACTIVE = "ACTIVE",
  BLOCK = 'BLOCK',
}

@Schema()
export class Users extends Document {
  @Prop({ type: String, default: 'ADMIN', enum: UserRole })
  type: string = 'ADMIN';

  @Prop({ type: String, default: null })
  email: string;

  @Prop({ type: String, default: null })
  name: string;

  @Prop({ type: String, default: null })
  company_logo: string;

  @Prop({ type: String, default: null })
  company_name: string;

  @Prop({ type: String, default: null })
  company_color: string;

  @Prop({ type: String, default: null })
  company_url: string;

  @Prop({ type: String, default: null })
  username: string;
  
  @Prop({ type: String, default: null })
  customer_id: string;
  
  @Prop({ default: false })
  super_admin: boolean = false;

  @Prop([
    {
      type: String,
      default: null
    },
  ])
  roles: string[];

  @Prop({ type: String, default: null })
  password: string;

  @Prop({ type: String, default: null })
  profile_pic: string;

  @Prop({ type: String, default: 0 })
  phone_no: String;

  @Prop({ type: String, default: null })
  country_code: string;

  @Prop({ type: String, default: null })
  country: string;

  @Prop({ type: Number, default: null })
  email_otp: number;

  @Prop({ type: Boolean, default: false })
  is_email_verified: boolean;

  @Prop({ type: Boolean, default: false })
  is_phone_verified: boolean;

  @Prop({
    type: String,
    default: Account_status.ACTIVATED,
    enum: Account_status,
  })
  account_status: string;

  @Prop({
    type: String,
    default: UserStatus.ACTIVE,
    enum: UserStatus,
  })
  status: string;

  @Prop({ type: Boolean, default: false })
  is_deleted: boolean;

  @Prop({ type: Boolean, default: true })
  ai_call_notification: Boolean;

  @Prop({ type: Boolean, default: true })
  ai_chat_notification: Boolean;

  @Prop({ type: Boolean, default: true })
  ai_human_notification: Boolean;

  @Prop({ type: [String] })
  module_permission?: string[];

  @Prop({ default: moment().utc().valueOf() })
  created_at: number = moment().utc().valueOf();

  @Prop({ default: moment().utc().valueOf() })
  updated_at: number = moment().utc().valueOf();
}

export const UserSchema = SchemaFactory.createForClass(Users);
