import {
  IsString,
  IsOptional,
  IsObject,
  ValidateNested,
  IsIn,
  IsBoolean,
} from 'class-validator';
import { Type } from 'class-transformer';

export class NotificationPreferencesDto {
  @IsOptional()
  @IsBoolean()
  pushEnabled?: boolean;

  @IsOptional()
  @IsBoolean()
  emailEnabled?: boolean;

  @IsOptional()
  @IsBoolean()
  feedingReminders?: boolean;

  @IsOptional()
  @IsBoolean()
  sleepReminders?: boolean;

  @IsOptional()
  @IsBoolean()
  diaperReminders?: boolean;

  @IsOptional()
  @IsBoolean()
  medicationReminders?: boolean;

  @IsOptional()
  @IsBoolean()
  milestoneAlerts?: boolean;

  @IsOptional()
  @IsBoolean()
  patternAnomalies?: boolean;
}

export class UserPreferencesDto {
  @IsOptional()
  @IsObject()
  @ValidateNested()
  @Type(() => NotificationPreferencesDto)
  notifications?: NotificationPreferencesDto;

  @IsOptional()
  @IsBoolean()
  emailUpdates?: boolean;

  @IsOptional()
  @IsBoolean()
  darkMode?: boolean;

  @IsOptional()
  @IsIn(['metric', 'imperial'])
  measurementUnit?: 'metric' | 'imperial';

  @IsOptional()
  @IsIn(['12h', '24h'])
  timeFormat?: '12h' | '24h';
}

export class UpdateProfileDto {
  @IsOptional()
  @IsString()
  name?: string;

  @IsOptional()
  @IsString()
  photoUrl?: string;

  @IsOptional()
  @IsString()
  locale?: string;

  @IsOptional()
  @IsString()
  timezone?: string;

  @IsOptional()
  @IsObject()
  @ValidateNested()
  @Type(() => UserPreferencesDto)
  preferences?: UserPreferencesDto;
}
