import { IsOptional, IsString, MaxLength, IsObject, ValidateNested, IsBoolean } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';

export class NotificationPrefsDto {
  @ApiPropertyOptional() @IsOptional() @IsBoolean() trade?: boolean;
  @ApiPropertyOptional() @IsOptional() @IsBoolean() expiry?: boolean;
  @ApiPropertyOptional() @IsOptional() @IsBoolean() marketing?: boolean;
}

export class UpdateSettingsDto {
  @ApiPropertyOptional({ description: 'Preferred language code', example: 'zh-CN' })
  @IsOptional() @IsString() @MaxLength(10)
  language?: string;

  @ApiPropertyOptional({ description: 'Preferred currency code', example: 'CNY' })
  @IsOptional() @IsString() @MaxLength(10)
  currency?: string;

  @ApiPropertyOptional({ description: 'Notification preferences' })
  @IsOptional() @IsObject() @ValidateNested() @Type(() => NotificationPrefsDto)
  notificationPrefs?: NotificationPrefsDto;
}
