import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ShopStatus } from '@prisma/client';
import {
  IsEnum,
  IsOptional,
  IsString,
  MaxLength,
  MinLength,
  ValidateIf,
} from 'class-validator';

export class SetShopStatusDto {
  @ApiProperty({ enum: ShopStatus, example: ShopStatus.APPROVED })
  @IsEnum(ShopStatus)
  status!: ShopStatus;

  @ApiPropertyOptional({
    example: 'Missing GST details. Please update GST number and resubmit.',
    description: 'Required when status=REJECTED',
  })
  @ValidateIf((o: SetShopStatusDto) => o.status === ShopStatus.REJECTED)
  @IsString()
  @MinLength(3)
  @MaxLength(500)
  reason?: string;

  @ApiPropertyOptional({
    example: 'Admin resubmitted documents, moved back to pending.',
    description:
      'Optional note when setting status=PENDING/APPROVED (stored as rejectedReason cleared anyway).',
  })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  note?: string;
}
