import {
  IsBoolean,
  IsDate,
  IsEmail,
  IsEnum,
  IsNotEmpty,
  IsOptional,
  IsString,
  IsUUID,
  Matches,
  MaxLength,
  MinLength,
} from "class-validator";
import { Type } from "class-transformer";
import { AccountType } from "@prisma/client";

export class UpdateUserDto {
  @IsString()
  @IsNotEmpty()
  name: string;

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

  @IsNotEmpty()
  @Matches(/^\d{10}$/, {
    message: "Phone number must be exactly 10 digits",
  })
  phone: string;

  @IsString()
  @IsOptional()
  @MinLength(6)
  @MaxLength(20)
  @Matches(/^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z\d])[A-Za-z\d\S]{6,20}$/, {
    message:
      "Password must contain at least one letter, one number and one special character",
  })
  password: string;

  @IsString()
  @IsOptional()
  description: string;

  @IsString()
  @IsOptional()
  profilePic: string;

  @IsBoolean()
  @IsOptional()
  isActive?: boolean;

  @IsOptional()
  @IsEnum(AccountType)
  role?: AccountType;

  @IsOptional()
  warehouseId: string;

  @IsBoolean()
  @IsOptional()
  isPermission?: boolean;
}
