small change

This commit is contained in:
paritosh18
2025-12-31 13:01:08 +05:30
parent 8199ce327a
commit ed3aaab961
2 changed files with 32 additions and 0 deletions

View File

@@ -136,6 +136,7 @@ export const CreateActivityDto = z.object({
equipmentIsChargeable: z.boolean().optional().default(false),
cancellationAvailable: z.boolean().optional().default(false),
cancellationAllowedBeforeMins:z.number().optional().default(null),
/* MONEY / CURRENCY */
currencyXid: z.number().int().nullable().optional(),

View File

@@ -2409,6 +2409,37 @@ export class HostService {
payload.alcoholAvailable = toBool(payload.alcoholAvailable);
payload.trainerTotalAmount = toNumber(payload.trainerTotalAmount);
payload.cancellationAllowedBeforeMins = toNumber(
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)',
);
}
if (
activityDurationMins > 0 &&
payload.cancellationAllowedBeforeMins >= activityDurationMins
) {
throw new ApiError(
400,
'cancellationAllowedBeforeMins must be less than activity duration',
);
}
} else {
delete payload.cancellationAllowedBeforeMins;
}
if (payload.trainerAvailable) {
if (