From 3ddaad0a463286c586291f18177b9be5ae5fa678 Mon Sep 17 00:00:00 2001 From: paritosh18 Date: Mon, 5 Jan 2026 14:47:24 +0530 Subject: [PATCH] suggestion is reviwed true --- src/modules/host/services/host.service.ts | 71 ++++++++++++++--------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/src/modules/host/services/host.service.ts b/src/modules/host/services/host.service.ts index 741ecf0..eba0a6e 100644 --- a/src/modules/host/services/host.service.ts +++ b/src/modules/host/services/host.service.ts @@ -107,7 +107,7 @@ const bucket = config.aws.bucketName; @Injectable() export class HostService { - constructor(private prisma: PrismaClient) { } + constructor(private prisma: PrismaClient) {} async createHost(data: CreateHostDto) { return this.prisma.user.create({ data }); @@ -549,9 +549,9 @@ export class HostService { id: true, energyLevelName: true, energyIcon: true, - energyColor: true - } - } + energyColor: true, + }, + }, }, }, }, @@ -770,7 +770,7 @@ export class HostService { if ( existingHostCompany && existingHostCompany.hostStatusInternal === - HOST_STATUS_INTERNAL.HOST_TO_UPDATE && + HOST_STATUS_INTERNAL.HOST_TO_UPDATE && !isDraft ) { hostStatusInternal = HOST_STATUS_INTERNAL.HOST_SUBMITTED; @@ -783,7 +783,7 @@ export class HostService { else if ( existingHostCompany && existingHostCompany.hostStatusInternal === - HOST_STATUS_INTERNAL.HOST_TO_UPDATE && + HOST_STATUS_INTERNAL.HOST_TO_UPDATE && isDraft ) { // keep original @@ -894,19 +894,19 @@ export class HostService { // Safely handle city connection - only connect if valid ID exists cities: parentCompanyData?.cityXid && - !isNaN(Number(parentCompanyData.cityXid)) + !isNaN(Number(parentCompanyData.cityXid)) ? { connect: { id: Number(parentCompanyData.cityXid) } } : undefined, states: parentCompanyData?.stateXid && - !isNaN(Number(parentCompanyData.stateXid)) + !isNaN(Number(parentCompanyData.stateXid)) ? { connect: { id: Number(parentCompanyData.stateXid) } } : undefined, countries: parentCompanyData?.countryXid && - !isNaN(Number(parentCompanyData.countryXid)) + !isNaN(Number(parentCompanyData.countryXid)) ? { connect: { id: Number(parentCompanyData.countryXid) } } : undefined, pinCode: parentCompanyData.pinCode || null, @@ -1056,19 +1056,19 @@ export class HostService { address2: parentCompanyData.address2 || null, cities: parentCompanyData?.cityXid && - !isNaN(Number(parentCompanyData.cityXid)) + !isNaN(Number(parentCompanyData.cityXid)) ? { connect: { id: Number(parentCompanyData.cityXid) } } : undefined, states: parentCompanyData?.stateXid && - !isNaN(Number(parentCompanyData.stateXid)) + !isNaN(Number(parentCompanyData.stateXid)) ? { connect: { id: Number(parentCompanyData.stateXid) } } : undefined, countries: parentCompanyData?.countryXid && - !isNaN(Number(parentCompanyData.countryXid)) + !isNaN(Number(parentCompanyData.countryXid)) ? { connect: { id: Number(parentCompanyData.countryXid) } } : undefined, pinCode: parentCompanyData.pinCode || null, @@ -1114,19 +1114,19 @@ export class HostService { address2: parentCompanyData.address2 || null, cities: parentCompanyData?.cityXid && - !isNaN(Number(parentCompanyData.cityXid)) + !isNaN(Number(parentCompanyData.cityXid)) ? { connect: { id: Number(parentCompanyData.cityXid) } } : undefined, states: parentCompanyData?.stateXid && - !isNaN(Number(parentCompanyData.stateXid)) + !isNaN(Number(parentCompanyData.stateXid)) ? { connect: { id: Number(parentCompanyData.stateXid) } } : undefined, countries: parentCompanyData?.countryXid && - !isNaN(Number(parentCompanyData.countryXid)) + !isNaN(Number(parentCompanyData.countryXid)) ? { connect: { id: Number(parentCompanyData.countryXid) } } : undefined, pinCode: parentCompanyData.pinCode || null, @@ -2039,11 +2039,11 @@ export class HostService { id: true, userRefNumber: true, firstName: true, - lastName: true - } - } - } - } + lastName: true, + }, + }, + }, + }, }, }); @@ -2374,7 +2374,6 @@ export class HostService { return v === true || v === 'true' || v === 1 || v === '1'; }; - const toNumber = (v: any) => v === undefined || v === null || v === '' ? undefined : Number(v); @@ -2510,9 +2509,9 @@ export class HostService { const rootTaxes = taxIds.length > 0 ? await this.prisma.taxes.findMany({ - where: { id: { in: taxIds }, isActive: true }, - select: { id: true, taxPer: true }, - }) + where: { id: { in: taxIds }, isActive: true }, + select: { id: true, taxPer: true }, + }) : []; if (taxIds.length !== rootTaxes.length) { @@ -2975,7 +2974,7 @@ export class HostService { await tx.activityPickUpTransport.deleteMany({ where: { - activityXid: Number(activityXid) + activityXid: Number(activityXid), }, }); @@ -2986,7 +2985,6 @@ export class HostService { if (Array.isArray(payload.pickupTransports)) { for (const transport of payload.pickupTransports) { - // ✅ CREATE TRANSPORT ONCE PER MODE const pickupTransport = await tx.activityPickUpTransport.create({ data: { @@ -2997,7 +2995,6 @@ export class HostService { if (Array.isArray(transport.pickupDetails)) { for (const detail of transport.pickupDetails) { - const totalPrice = toNumber(detail.transportTotalPrice) ?? 0; const { basePrice, taxDetails } = computeBasePriceAndTaxes( @@ -3034,7 +3031,6 @@ export class HostService { } } - /* -------------------------------- * 1️⃣2️⃣ CLEAN & CREATE NAVIGATION MODES WITH TAXES * -------------------------------- */ @@ -3235,6 +3231,25 @@ export class HostService { }); } + /* -------------------------------- + * ✅ MARK ACTIVITY SUGGESTIONS AS REVIEWED + * (REJECTED → ENHANCE → SUBMIT FLOW) + * -------------------------------- */ + if (wasRejected && !isDraft) { + await tx.activitySuggestions.updateMany({ + where: { + activityXid: activityXid, + isActive: true, + isReviewed: false, + }, + data: { + isReviewed: true, + reviewedByXid: userId, + reviewedOn: new Date(), + }, + }); + } + /* -------------------------------- * 1️⃣8️⃣ ACTIVITY TRACK * -------------------------------- */