import { ApiProperty } from '@nestjs/swagger';
// import { Language } from '@prisma/client';
import {
  IsEmail,
  IsMobilePhone,
  IsNotEmpty,
  IsNumberString,
  IsOptional,
  IsString,
  Length,
  MaxLength,
  MinLength,
} from 'class-validator';
import { Match } from '../decorators/match.decorator';

export class AdminLoginGoogle {
  @ApiProperty({ example: 'token', type: 'string' })
  @IsString()
  @IsNotEmpty()
  google_token!: string;
}

export class UserLogin {
  @ApiProperty({ example: 'username', type: 'string' })
  @IsString()
  @IsNotEmpty()
  username!: string;

  @ApiProperty({ example: 'password', type: 'string' })
  @IsString()
  @IsNotEmpty()
  password!: string;
}

export class TenantSignUp {
  @ApiProperty({ example: 'abc@gmail,com', type: 'string' })
  @IsString()
  @IsOptional()
  email: string;

  @ApiProperty({ example: 'street', type: 'string' })
  @IsString()
  @IsOptional()
  street: string;

  @ApiProperty({ example: 'city', type: 'string' })
  @IsString()
  @IsOptional()
  city: string;

  @ApiProperty({ example: 'province', type: 'string' })
  @IsString()
  @IsOptional()
  province: string;

  @ApiProperty({ example: '100000', type: 'string' })
  @IsString()
  @IsOptional()
  postal_code: string;

  @ApiProperty({ example: 'B', type: 'string' })
  @IsString()
  @IsOptional()
  first_name: string;

  @ApiProperty({ example: 'A', type: 'string' })
  @IsString()
  @IsOptional()
  last_name: string;

  @ApiProperty({ example: '09658623548', type: 'string' })
  @IsMobilePhone('vi-VN')
  @IsNotEmpty()
  phone: string;

  @ApiProperty({ example: 'username', type: 'string' })
  @IsString()
  @IsNotEmpty()
  username!: string;

  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @MinLength(8)
  @MaxLength(20)
  // @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {
  //   message: 'password too weak',
  // })
  password!: string;

  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @Match('password')
  password_confirmation: string;
}

export class UserSignUp {
  @ApiProperty({ example: 'A', type: 'string' })
  @IsString()
  @IsOptional()
  fullname: string;

  @ApiProperty({ example: '0965862358', type: 'string' })
  @IsMobilePhone('vi-VN')
  @IsNotEmpty()
  phone: string;

  @ApiProperty({ example: 'abc@gmail,com', type: 'string' })
  @IsOptional()
  @IsEmail()
  email: string;

  @ApiProperty({ example: 'username', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(15)
  username!: string;

  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @MinLength(6)
  @MaxLength(20)
  // @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {
  //   message: 'password too weak',
  // })
  password!: string;

  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @Match('password')
  password_confirmation: string;
}

export class UserConfirmSignUp {
  @ApiProperty({ example: 'abc@gmail,com', type: 'string' })
  @IsString()
  id: string;

  @ApiProperty({ example: '123456', type: 'string' })
  @IsNumberString()
  @IsNotEmpty()
  @Length(6, 6)
  otp: string;
}

export class ChangePassword {
  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsOptional()
  @MaxLength(32)
  // @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {
  //   message: 'password too weak',
  // })
  old_password!: string;

  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @MinLength(8)
  @MaxLength(32)
  // @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/, {
  //   message: 'password too weak',
  // })
  password!: string;

  @ApiProperty({ example: 'POSvQUfwxG', type: 'string' })
  @IsString()
  @IsNotEmpty()
  @Match('password')
  password_confirmation: string;
}