import {
  IsString,
  IsOptional,
  MaxLength,
  IsUUID,
  IsIn,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateStoreDto {
  @ApiProperty({ maxLength: 200 })
  @IsString()
  @MaxLength(200)
  name: string;

  @ApiPropertyOptional({ maxLength: 500 })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  address?: string;

  @ApiPropertyOptional({ maxLength: 20 })
  @IsOptional()
  @IsString()
  @MaxLength(20)
  phone?: string;

  @ApiPropertyOptional({ enum: ['hq', 'region', 'store'], default: 'store' })
  @IsOptional()
  @IsString()
  @IsIn(['hq', 'region', 'store'])
  level?: string;

  @ApiPropertyOptional({ description: 'UUID of the parent store' })
  @IsOptional()
  @IsUUID()
  parentId?: string;
}

export class UpdateStoreDto {
  @ApiPropertyOptional({ maxLength: 200 })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  name?: string;

  @ApiPropertyOptional({ maxLength: 500 })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  address?: string;

  @ApiPropertyOptional({ maxLength: 20 })
  @IsOptional()
  @IsString()
  @MaxLength(20)
  phone?: string;

  @ApiPropertyOptional({ enum: ['hq', 'region', 'store'] })
  @IsOptional()
  @IsString()
  @IsIn(['hq', 'region', 'store'])
  level?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsUUID()
  parentId?: string;

  @ApiPropertyOptional({ enum: ['active', 'inactive', 'closed'] })
  @IsOptional()
  @IsString()
  @IsIn(['active', 'inactive', 'closed'])
  status?: string;
}

export class ListStoresQueryDto {
  @ApiPropertyOptional({ enum: ['hq', 'region', 'store'] })
  @IsOptional()
  @IsString()
  level?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsUUID()
  parentId?: string;

  @ApiPropertyOptional({ enum: ['active', 'inactive', 'closed'] })
  @IsOptional()
  @IsString()
  status?: string;
}
