// 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';

// import {Types}
const genders = ['MALE', 'FEMALE', 'OTHERS'];
const device_types = ['ANDROID', 'IOS', 'WEB'];
const social_type = [null, 'APPLE', 'GOOGLE', 'FACEBOOK', 'INSTAGRAM'];
export enum Account_status {
  ACTIVATED = 'ACTIVATED',
  DEACTIVATED = 'DEACTIVATED',
  PENDING = 'PENDING',
}
const type = [
  null,
  'USER',
  'ADMIN',
  'STAFF',
  'CHEF',
  'DRIVER',
  'AGENT',
  'FARMER',
];
const status = ['UNDER_REVIEW', 'ACCEPTED', 'REJECTED'];
const driver_status = ['PENDING', 'LOGIN'];
const driver_availabillity_status = ['AVAILABLE', 'OFFLINE', 'OCCUPIED'];
const chef_availabillity_status = ['AVAILABLE', 'OFFLINE'];

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

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

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

  @Prop({ type: String, default: null })
  username: 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: Number, default: 0 })
  phone_no: number;

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

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

  @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: Boolean, default: true })
  is_notification_visable: Boolean;


  @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);
UserSchema.index({ loc: '2dsphere' });
