import { IsEmail, IsNotEmpty, IsOptional } from "class-validator";
import { ApiProperty,PartialType } from '@nestjs/swagger';
import { extname } from "path";
import exp from "constants";

export class SignupDto  {

  @IsNotEmpty()
  @ApiProperty()
  full_name: string;
  
  @IsNotEmpty()
  @ApiProperty()
  email: string;

  @IsNotEmpty()
  @ApiProperty()
  password: string;

  @ApiProperty()
  city: string;

  @ApiProperty()
  location: string;  

  @ApiProperty()
  nationality: string;

  @ApiProperty()
  job_title: string;

  @ApiProperty()
  job_type: string;

  @ApiProperty()
  contact_no: string;
 
  
  }

  export class CreateClientDto {
    @IsNotEmpty()
    @ApiProperty()
    client_name: string;

    @IsNotEmpty()
    @ApiProperty()
    user_id: number;

}

export class CreateVendorDto {

  @IsNotEmpty()
  @ApiProperty()
  vendor_name: string;

  @IsNotEmpty()
  @ApiProperty()
  user_id: number;

}


export class UpdateClientDto {
    
  @IsNotEmpty()
  @ApiProperty()
  client_name: string;

  @IsNotEmpty()
  @ApiProperty()
  user_id: number;
}



export class LoginDto {
   
    @ApiProperty()
    email: string;

   
    @ApiProperty()
    phoneNo: string;
  
    @IsNotEmpty()
    @ApiProperty()
    password: string;
 }

 export class AddRoleDto {
   
  @ApiProperty()
  role_name: string;

}

 export class NotificationDto {
   
  @ApiProperty()
  userId: number;

 
  @ApiProperty()
  notification_status: number;

}


export class addNotificationDto {
   
  @ApiProperty()
  notification_text: string;

  @ApiProperty()
  notification_phone: string;

  @ApiProperty()
  user_id: number;

}


export class addCustomerAddressDto {
   
  @ApiProperty()
  country: string;

  @ApiProperty()
  city: string;

  @ApiProperty()
  location: string;

  @ApiProperty()
  latitude: string;

  @ApiProperty()
  longitude: string;

  @ApiProperty()
  user_id: number;

}

export class addCustomerFeedbackDto{
  @ApiProperty()
  customer_name: string;

  @ApiProperty()
  remarks: string;

  @ApiProperty()
  user_id: number;

  @ApiProperty()
  rating: number;

}

export class addCustomerSupportDto {
   
  @ApiProperty()
  name: string;

  @ApiProperty()
  email: string;

  @ApiProperty()
  phone: string;

  @ApiProperty()
  message: string;

  @ApiProperty()
  created_at: Date;

  @ApiProperty()
  user_id: number;

}


export class CreateCustomerCarDto {

    @ApiProperty()
    year_id: string;

    @ApiProperty()
    user_id: number;
  
    @ApiProperty()
    make_id: string;
  
    @ApiProperty()
    model_id: string;

    @ApiProperty()
    plate_number: string;

    @ApiProperty()
    vin_number: string;

    @ApiProperty()
    attachment: string;
} 

export class UpdateCustomerCarDto {

  @ApiProperty()
  year_id: string;

  @ApiProperty()
  user_id: number;

  @ApiProperty()
  car_id: number;

  @ApiProperty()
  make_id: string;

  @ApiProperty()
  model_id: string;

  @ApiProperty()
  plate_number: string;

  @ApiProperty()
  vin_number: string;

  @ApiProperty()
  attachment: string;
} 


  export class UserUpdateDto{
      
  @IsNotEmpty()
  @ApiProperty()
  full_name: string;

  @IsNotEmpty()
  @ApiProperty()
  email: string;

  @IsNotEmpty()
  @ApiProperty()
  password: string;

  @ApiProperty({
    default:null,
    })
    city: string;

  @ApiProperty()
  client_id: number;  

  @ApiProperty()
  project_id: number;  

  @ApiProperty()
  department_id:number;

  @ApiProperty()
  designation:string;

  @ApiProperty()
  location: string;  

  @ApiProperty()
  nationality: string;

  @ApiProperty()
  job_title: string;

  @ApiProperty()
  job_type: string;

  @ApiProperty()
  contact_no: string;
  
  }
  


  export class ForgotDto {
  
    @ApiProperty()
    email: string;

    @IsNotEmpty()
    @ApiProperty()
    password: string;
}

export const editFileName = (req, file, callback) => {
  const name = file.originalname.split('.')[0];
  const curren_data_time = new Date().getTime()
  const fileExtName = extname(file.originalname);
  const randomName = Array(4)
    .fill(null)
    .map(() => curren_data_time+Math.round(Math.random() * 4).toString(5))
    .join('');
  callback(null, `${randomName}${fileExtName}`);
};

export const imageFileFilter = (req, file, callback) => {
if (!file.originalname.match(/\.(jpg|jpeg|png|gif)$/)) {
  return callback(new Error('Only image files are allowed!'), false);
}
callback(null, true);
};  