42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { Type } from "class-transformer";
|
|
import {
|
|
IsArray,
|
|
IsIn,
|
|
IsInt,
|
|
IsISO8601,
|
|
IsOptional,
|
|
IsObject,
|
|
IsString,
|
|
Max,
|
|
Min,
|
|
ValidateNested,
|
|
} from "class-validator";
|
|
|
|
export class BookingItemDto {
|
|
@IsString() offeringId!: string;
|
|
@IsInt() @Min(1) @Max(50) quantity!: number;
|
|
}
|
|
|
|
export class CreateBookingDto {
|
|
@IsIn(["package", "private_chef", "inquiry"]) requestType!:
|
|
"package" | "private_chef" | "inquiry";
|
|
@IsString() customerName!: string;
|
|
@IsOptional() @IsString() phone?: string;
|
|
@IsOptional() @IsString() wechatId?: string;
|
|
@IsIn(["wechat", "phone", "none"]) contactPreference!: "wechat" | "phone" | "none";
|
|
@IsOptional() @IsIn(["pickup", "delivery"]) fulfillmentType?: "pickup" | "delivery";
|
|
@IsOptional() @IsString() offeringId?: string;
|
|
@IsOptional() @IsISO8601() requestedDate?: string;
|
|
@IsOptional() @IsString() requestedTime?: string;
|
|
@IsOptional() @IsString() deliveryAddress?: string;
|
|
@IsOptional() @IsString() note?: string;
|
|
@IsOptional() extraData?: Record<string, unknown>;
|
|
@IsArray() @ValidateNested({ each: true }) @Type(() => BookingItemDto) items: BookingItemDto[] =
|
|
[];
|
|
}
|
|
|
|
export class CreateInquirySubmissionDto {
|
|
@IsString() formId!: string;
|
|
@IsObject() values!: Record<string, unknown>;
|
|
}
|