small change
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user