import {
  IsString,
  IsNotEmpty,
  IsOptional,
  IsEmail,
  IsEnum,
  IsInt,
  Min,
  Matches,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export enum LicenseType {
  STARTER = 'STARTER',
  STANDARD = 'STANDARD',
  PREMIUM = 'PREMIUM',
}

export class CreateClubDto {
  @ApiProperty({ description: 'Club display name', example: 'FitLife Moscow' })
  @IsString()
  @IsNotEmpty()
  name: string;

  @ApiProperty({
    description: 'URL-safe slug (lowercase, digits, hyphens)',
    example: 'fitlife-moscow',
  })
  @IsString()
  @IsNotEmpty()
  @Matches(/^[a-z0-9-]+$/, {
    message: 'slug must contain only lowercase letters, digits, and hyphens',
  })
  slug: string;

  @ApiPropertyOptional({ description: 'Club physical address' })
  @IsString()
  @IsOptional()
  address?: string;

  @ApiPropertyOptional({ description: 'Club phone number' })
  @IsString()
  @IsOptional()
  phone?: string;

  @ApiPropertyOptional({ description: 'Club contact email' })
  @IsEmail()
  @IsOptional()
  email?: string;

  @ApiPropertyOptional({
    description: 'License type',
    enum: LicenseType,
    default: LicenseType.STARTER,
  })
  @IsEnum(LicenseType)
  @IsOptional()
  licenseType?: LicenseType = LicenseType.STARTER;

  @ApiPropertyOptional({
    description: 'Maximum number of active users',
    default: 5,
  })
  @IsInt()
  @Min(1)
  @IsOptional()
  maxUsers?: number = 5;

  @ApiPropertyOptional({
    description: 'Maximum number of client records',
    default: 100,
  })
  @IsInt()
  @Min(1)
  @IsOptional()
  maxClients?: number = 100;
}
