import {
  IsNumber,
  IsOptional,
  IsString,
  MaxLength,
  Min,
  Max,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateShopDto {
  @ApiProperty({ example: 'Cashi Main Store' })
  @IsString()
  @MaxLength(120)
  name!: string;

  @ApiProperty({ example: 'cashi-main-store' })
  @IsString()
  @MaxLength(30)
  username!: string; // stored without "@", validated in service

  @ApiProperty({ example: '12, MG Road, Near Metro Station' })
  @IsString()
  @MaxLength(255)
  address!: string;

  @ApiProperty({ example: 'Mumbai' })
  @IsString()
  @MaxLength(80)
  city!: string;

  @ApiProperty({ example: 'Maharashtra' })
  @IsString()
  @MaxLength(80)
  state!: string;

  @ApiProperty({ example: '400001' })
  @IsString()
  @MaxLength(12)
  pincode!: string;

  @ApiPropertyOptional({ example: '27AAACR5055K1Z5' })
  @IsOptional()
  @IsString()
  @MaxLength(32)
  gstNo?: string;

  @ApiPropertyOptional({ example: 'yourstore@upi' })
  @IsOptional()
  @IsString()
  @MaxLength(120)
  upiId?: string;

  @ApiProperty({ example: 'cmnxxxxxx' })
  @IsString()
  @MaxLength(80)
  businessTypeId!: string;

  @ApiPropertyOptional({ example: 'https://...' })
  @IsOptional()
  @IsString()
  @MaxLength(2000)
  imageUrl?: string;

  @ApiPropertyOptional({ example: 28.6139, description: 'Latitude (optional)' })
  @IsOptional()
  @IsNumber()
  @Min(-90)
  @Max(90)
  latitude?: number;

  @ApiPropertyOptional({ example: 77.209, description: 'Longitude (optional)' })
  @IsOptional()
  @IsNumber()
  @Min(-180)
  @Max(180)
  longitude?: number;

  @ApiProperty({ example: 'BASIC' })
  @IsString()
  @MaxLength(30)
  planCode!: string;
}
