import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';

@Schema({ timestamps: true })
export class User {
  @Prop({ default: '', lowercase: true })
  first_name: string;

  @Prop({ default: '', lowercase: true })
  last_name: string;

  @Prop({ default: '', collation: { locale: 'en', strength: 2 } })
  username: string;

  @Prop({ default: '', collation: { locale: 'en', strength: 2 } })
  email: string;

  @Prop()
  phone_number: string;

  @Prop({ default: '', lowercase: true })
  company_name: string;

  @Prop({ default: false })
  is_company: boolean;

  @Prop({ default: '' })
  password: string;

  @Prop({ default: '' })
  city: string;

  @Prop({ default: '' })
  country: string;

  @Prop({ default: '' })
  country_phone_code: string;

  @Prop({ default: false })
  is_admin: boolean;

  // @Prop({ default: false })
  // is_warehouse_admin: boolean;

  @Prop({ default: null })
  deleted_at: Date;

  @Prop({ default: false })
  is_blocked: boolean;

  @Prop({ default: null })
  last_login: Date;

  @Prop({ enum: ['AR', 'EN'], default: 'EN' })
  lang: string;

  @Prop({ default: null })
  phone_number_verified_at: Date;

  @Prop({
    enum: ['admin', 'user'],
    default: 'user',
    required: false,
  })
  created_by?: 'admin' | 'user';
}

export const UserSchema = SchemaFactory.createForClass(User);
export type UserDocument = User & Document;
