import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsNotEmpty, IsOptional, IsString, Length } from 'class-validator';

export class CreateSucursaleDto {
  @ApiProperty({ example: 'cd88ac6a-2b0e-41bc-afd9-24b594cb8daf' })
  @IsNotEmpty({ message: 'Empresa es obligatoria' })
  empresa_id: string;

  @ApiProperty({ example: '001' })
  @IsString({ message: 'Punto establecimiento debe ser un string' })
  @IsNotEmpty({ message: 'Punto establecimiento es obligatorio, debe ' })
  @Length(3, 3, { message: 'Punto establecimiento debe tener exactamente 3 dígitos' })
  punto_establecimiento: string;

  @ApiProperty({ example: 'Descripción' })
  @IsNotEmpty({ message: 'Descripción es obligatoria' })
  descripcion: string;

  /**
   * Nombre comercial que se imprime en el ticket. Vacío = se usa el de la
   * empresa (mismo criterio que el logo propio de la sucursal).
   */
  @ApiProperty({ example: 'Agogo Regalos', required: false })
  @IsOptional()
  @IsString({ message: 'Nombre de fantasía debe ser un string' })
  @Length(0, 100, { message: 'Nombre de fantasía debe tener hasta 100 caracteres' })
  nombre_fantasia?: string;

  @ApiProperty({ example: 'Dirección' })
  @IsNotEmpty({ message: 'Dirección es obligatoria' })
  direccion: string;

  @ApiProperty({ example: '0' })
  @IsNotEmpty({ message: 'Número casa es obligatorio, completar con 0 si no aplica' })
  numero_casa: string;

  @ApiProperty({ example: '253381af-b7e6-4c2f-9e90-33be1aea687b' })
  @IsNotEmpty({ message: 'País es obligatorio' })
  pais_id: string;

  @ApiProperty({ example: 'f6d5800b-1d7c-4858-b346-64054e9fd243' })
  @IsNotEmpty({ message: 'Departamento es obligatorio' })
  departamento_id: string;

  @ApiProperty({ example: '17da5340-1b15-482d-bd8a-11a03595acfe' })
  @IsNotEmpty({ message: 'Distrito es obligatorio' })
  distrito_id: string;

  @ApiProperty({ example: 'abd791ce-28d3-4fba-9af1-ed41af9c4eea' })
  @IsNotEmpty({ message: 'Ciudad es obligatoria' })
  ciudad_id: string;

  @ApiProperty({ example: '0210000000' })
  @IsOptional()
  @Length(6, 15, { message: 'Telefono debe tener entre 6 y 15 caracteres' })
  telefono?: string;

  @ApiProperty({ example: 'email@example.com' })
  @IsOptional()
  @IsEmail({}, { message: 'Email debe tener un formato válido' })
  @Length(3, 80, { message: 'Email debe tener entre 3 y 80 caracteres' })
  email?: string;

  @IsOptional()
  complemento_1?: string;

  @IsOptional()
  complemento_2?: string;

  @IsOptional()
  usuario?: string;
}
