From 401734096dcfe1641129ca96a685bc653c2e0ba6 Mon Sep 17 00:00:00 2001 From: paritosh18 Date: Wed, 31 Dec 2025 13:03:23 +0530 Subject: [PATCH] sml chng --- src/modules/host/dto/createActivity.schema.ts | 5 +- src/modules/host/services/host.service.ts | 75 ++++++++++--------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/modules/host/dto/createActivity.schema.ts b/src/modules/host/dto/createActivity.schema.ts index c232f2b..02dbdab 100644 --- a/src/modules/host/dto/createActivity.schema.ts +++ b/src/modules/host/dto/createActivity.schema.ts @@ -21,7 +21,7 @@ export const PriceDto = z.object({ /* ================= VENUE ================= */ export const VenueDto = z.object({ venueName: z.string(), - venueLabel:z.string(), + venueLabel: z.string(), venueCapacity: z.number().int().optional().default(0), availableSeats: z.number().int().optional().default(0), isMinPeopleReqMandatory: z.boolean().optional().default(false), @@ -45,7 +45,6 @@ export const PickupDetailDto = z.object({ transportTotalPrice: z.number().int().min(1), }); - export const PickupTransportDto = z.object({ transportModeXid: z.number().int(), pickupDetails: z.array(PickupDetailDto).optional().default([]), @@ -136,7 +135,7 @@ export const CreateActivityDto = z.object({ equipmentIsChargeable: z.boolean().optional().default(false), cancellationAvailable: z.boolean().optional().default(false), - cancellationAllowedBeforeMins:z.number().optional().default(null), + cancellationAllowedBeforeMins: z.number().int().nullable().optional(), /* MONEY / CURRENCY */ currencyXid: z.number().int().nullable().optional(), diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index e042941..5c18e38 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -1812,15 +1812,15 @@ export class HostService { select: { countryName: true, countryCode: true, - countryFlag: true - } + countryFlag: true, + }, }, taxName: true, taxPer: true, - } - } - } - } + }, + }, + }, + }, }, }, }, @@ -1869,12 +1869,12 @@ export class HostService { }, ActivityFoodCost: { where: { - isActive: true + isActive: true, }, select: { id: true, - totalAmount: true - } + totalAmount: true, + }, }, activityCuisines: { where: { @@ -2410,36 +2410,36 @@ export class HostService { payload.trainerTotalAmount = toNumber(payload.trainerTotalAmount); payload.cancellationAllowedBeforeMins = toNumber( - payload.cancellationAllowedBeforeMins, - ); + payload.cancellationAllowedBeforeMins, + ); - /* ===================================================== - * CANCELLATION VALIDATION (NO CONVERSION) - * ===================================================== */ - if (payload.cancellationAvailable) { - if ( - typeof payload.cancellationAllowedBeforeMins !== 'number' || - Number.isNaN(payload.cancellationAllowedBeforeMins) || - payload.cancellationAllowedBeforeMins <= 0 - ) { - throw new ApiError( - 400, - 'cancellationAllowedBeforeMins must be a positive number (in minutes)', - ); - } + /* ===================================================== + * CANCELLATION VALIDATION (NO CONVERSION) + * ===================================================== */ + if (payload.cancellationAvailable) { + if ( + typeof payload.cancellationAllowedBeforeMins !== 'number' || + Number.isNaN(payload.cancellationAllowedBeforeMins) || + payload.cancellationAllowedBeforeMins <= 0 + ) { + throw new ApiError( + 400, + 'cancellationAllowedBeforeMins must be a positive number (in minutes)', + ); + } - if ( - activityDurationMins > 0 && - payload.cancellationAllowedBeforeMins >= activityDurationMins - ) { - throw new ApiError( - 400, - 'cancellationAllowedBeforeMins must be less than activity duration', - ); + if ( + activityDurationMins > 0 && + payload.cancellationAllowedBeforeMins >= activityDurationMins + ) { + throw new ApiError( + 400, + 'cancellationAllowedBeforeMins must be less than activity duration', + ); + } + } else { + delete payload.cancellationAllowedBeforeMins; } - } else { - delete payload.cancellationAllowedBeforeMins; - } if (payload.trainerAvailable) { if ( @@ -2628,6 +2628,9 @@ export class HostService { equipmentAvailable: payload.equipmentAvailable, equipmentIsChargeable: toBool(payload.equipmentIsChargeable), cancellationAvailable: payload.cancellationAvailable, + cancellationAllowedBeforeMins: payload.cancellationAvailable + ? payload.cancellationAllowedBeforeMins + : null, activityInternalStatus, activityDisplayStatus,