import { typeParser } from '@lib/utils/type-parser';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Expose, Transform } from 'class-transformer';
import { IsEnum, IsInt, IsOptional, IsString } from 'class-validator';

enum RefundState {
  REF001 = 'REF001', //환불완료
  REF002 = 'REF002', //환불반려
}
export class Refund {
  @Expose()
  @ApiProperty({ description: '환불 id' })
  @Transform(({ value }) => typeParser.int(value))
  @IsInt()
  refId!: number;

  @Expose()
  @ApiProperty({
    description: `환불상태(환불완료 : REF001 | 환불반려 : REF002)`,
    enum: RefundState,
  })
  @IsEnum(RefundState)
  refState!: RefundState;

  @Expose()
  @ApiPropertyOptional({ description: '환불은행명' })
  @IsString()
  @IsOptional()
  refBank?: string;

  @Expose()
  @ApiPropertyOptional({ description: '환불예금주명' })
  @IsString()
  @IsOptional()
  refAccountName?: string;

  @Expose()
  @ApiPropertyOptional({ description: '환불rmador' })
  @IsInt()
  @IsOptional()
  refPrice?: number;

  @Expose()
  @ApiPropertyOptional({ description: '환불메모' })
  @IsString()
  @IsOptional()
  refMemo?: string;

  @Expose()
  @ApiPropertyOptional({ description: '환불계좌번호' })
  @IsString()
  @IsOptional()
  refAccountNumber?: string;

  @Expose()
  @ApiPropertyOptional({ description: '환불 완료일시' })
  @IsString()
  @IsOptional()
  refCompletedAt?: string;

  @Expose()
  @ApiPropertyOptional({ description: '환불 수정일시' })
  @IsString()
  @IsOptional()
  refUpdatedAt?: string;

  @Expose()
  @ApiProperty({ description: '환불 생성일시' })
  @IsString()
  refCreatedAt!: string;
}
