From 3f96dd4ae1145eccd4887f278ee8dc535426e932 Mon Sep 17 00:00:00 2001 From: paritosh18 Date: Wed, 25 Feb 2026 14:41:58 +0530 Subject: [PATCH] feat: Add safety instructions and cancellations fields to activity details --- prisma/schema.prisma | 2 ++ src/modules/host/dto/createActivity.schema.ts | 2 ++ .../Activity_Hub/OnBoarding/CreateNewActivity.ts | 15 ++++++++++++++- src/modules/host/services/host.service.ts | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0b7cd08..3620bf4 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1036,6 +1036,8 @@ model ActivityOtherDetails { activityXid Int @map("activity_xid") activity Activities @relation(fields: [activityXid], references: [id], onDelete: Cascade) exclusiveNotes String? @map("exclusive_notes") @db.VarChar(500) + SafetyInstruction String? @map("safety_instruction") @db.VarChar(400) + Cancellations String? @map("cancellations") @db.VarChar(400) dosNotes String? @map("dos_notes") @db.VarChar(400) dontsNotes String? @map("donts_notes") @db.VarChar(400) tipsNotes String? @map("tips_notes") @db.VarChar(400) diff --git a/src/modules/host/dto/createActivity.schema.ts b/src/modules/host/dto/createActivity.schema.ts index 7a74bf1..c03f0bb 100644 --- a/src/modules/host/dto/createActivity.schema.ts +++ b/src/modules/host/dto/createActivity.schema.ts @@ -86,10 +86,12 @@ export const EligibilityDto = z.object({ /* ================= OTHER DETAILS ================= */ export const OtherDetailsDto = z.object({ exclusiveNotes: z.string().optional(), + safetyInstruction: z.string().optional(), dosNotes: z.string().optional(), dontsNotes: z.string().optional(), tipsNotes: z.string().optional(), termsAndCondition: z.string().optional(), + cancellations: z.string().optional(), }); /* ================= CREATE ACTIVITY ================= */ diff --git a/src/modules/host/handlers/Activity_Hub/OnBoarding/CreateNewActivity.ts b/src/modules/host/handlers/Activity_Hub/OnBoarding/CreateNewActivity.ts index 1a31d78..b0b8a8e 100644 --- a/src/modules/host/handlers/Activity_Hub/OnBoarding/CreateNewActivity.ts +++ b/src/modules/host/handlers/Activity_Hub/OnBoarding/CreateNewActivity.ts @@ -1,4 +1,3 @@ -import config from '../../../../../config/config'; import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; import { prismaClient } from '../../../../../common/database/prisma.lambda.service'; import { verifyHostToken } from '../../../../../common/middlewares/jwt/authForHost'; @@ -62,6 +61,20 @@ export const handler = safeHandler( isCoverImage: m.isCoverImage ?? false, })); + /* 4.1️⃣ ATTACH SAFETY INSTRUCTIONS (string only) */ + if (activity.safetyInstruction !== undefined && activity.safetyInstruction !== null) { + if (typeof activity.safetyInstruction !== 'string') { + throw new ApiError(400, 'safetyInstruction must be a string'); + } + } + + /* 4.2️⃣ ATTACH CANCELLATIONS (string only) */ + if (activity.cancellations !== undefined && activity.cancellations !== null) { + if (typeof activity.cancellations !== 'string') { + throw new ApiError(400, 'cancellations must be a string'); + } + } + /* 5️⃣ VALIDATION */ let parsedDto: CreateActivityInput; diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index f51d96f..7437b58 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -3494,6 +3494,22 @@ export class HostService { data: { activityXid, exclusiveNotes: payload.otherDetails.exclusiveNotes ?? null, + SafetyInstruction: (() => { + const s = payload.otherDetails.safetyInstruction ?? null; + if (s === undefined || s === null) return null; + if (typeof s !== 'string') { + throw new ApiError(400, 'safetyInstruction must be a string'); + } + return s; + })(), + Cancellations: (() => { + const c = payload.otherDetails.cancellations ?? null; + if (c === undefined || c === null) return null; + if (typeof c !== 'string') { + throw new ApiError(400, 'cancellations must be a string'); + } + return c; + })(), dosNotes: payload.otherDetails.dosNotes ?? null, dontsNotes: payload.otherDetails.dontsNotes ?? null, tipsNotes: payload.otherDetails.tipsNotes ?? null,