saving the start stop details and sending it in the get api for the itinerary

This commit is contained in:
2026-04-08 15:57:36 +05:30
parent be0667d8e9
commit 9df8c5443c
3 changed files with 142 additions and 7 deletions

View File

@@ -51,18 +51,18 @@ export async function sendWelcomeEmailToHost(
const subject = "Get Started as a Minglar Host"; const subject = "Get Started as a Minglar Host";
const htmlContent = ` const htmlContent = `
<p>Hi ${emailAddress}</p><br/><br/> <p>Hi ${emailAddress}</p><br/>
<p>Were excited to have you join Minglar as a host. Welcome aboard! 🌟</p><br/><br/> <p>Were excited to have you join Minglar as a host. Welcome aboard! 🌟</p><br/>
<p>To get started and bring your activities live, heres what comes next:</p><br/><br/> <p>To get started and bring your activities live, heres what comes next:</p><br/>
<p><strong>Your next steps:</strong></p><br/> <p><strong>Your next steps:</strong></p><br/>
<p>1. Complete your host profile</p><br/> <p>1. Complete your host profile</p><br/>
<p>2. Complete the pre-qualification process for all your activities</p><br/> <p>2. Complete the pre-qualification process for all your activities</p><br/>
<p>3. Submit your activity details for review</p><br/> <p>3. Submit your activity details for review</p><br/>
<p>4. Go live and start receiving bookings</p><br/><br/> <p>4. Go live and start receiving bookings</p><br/>
<p><strong>👉 Access your Host Portal:</strong></p><br/> <p><strong>👉 Access your Host Portal:</strong></p><br/>
<p>${config.HOST_LINK}</p><br/><br/><br/> <p>${config.HOST_LINK}</p><br/><br/>
<p>If you need any support along the way, our team is always here to help. You can reach us anytime at info@minglargroup.com.</p><br/><br/> <p>If you need any support along the way, our team is always here to help. You can reach us anytime at info@minglargroup.com.</p><br/>
<p>Were looking forward to seeing your experiences come to life on Minglar.</p><br/><br/> <p>Were looking forward to seeing your experiences come to life on Minglar.</p><br/>
<p>Warm regards,<br/>Team Minglar</p> <p>Warm regards,<br/>Team Minglar</p>
`; `;

View File

@@ -44,6 +44,35 @@ export const handler = safeHandler(async (
); );
} }
if (
body.startLocationAddress === undefined ||
body.startLocationAddress === null ||
body.startLocationLat === undefined ||
body.startLocationLat === null ||
body.startLocationLong === undefined ||
body.startLocationLong === null ||
body.endLocationAddress === undefined ||
body.endLocationAddress === null ||
body.endLocationLat === undefined ||
body.endLocationLat === null ||
body.endLocationLong === undefined ||
body.endLocationLong === null
) {
throw new ApiError(
400,
'startLocationAddress, startLocationLat, startLocationLong, endLocationAddress, endLocationLat and endLocationLong are required.',
);
}
if (
(typeof body.startLocationAddress === 'string' &&
!body.startLocationAddress.trim()) ||
(typeof body.endLocationAddress === 'string' &&
!body.endLocationAddress.trim())
) {
throw new ApiError(400, 'Location addresses cannot be empty.');
}
if (!activities.length) { if (!activities.length) {
throw new ApiError(400, 'At least one activity is required.'); throw new ApiError(400, 'At least one activity is required.');
} }
@@ -107,6 +136,24 @@ export const handler = safeHandler(async (
endDate: body.endDate, endDate: body.endDate,
startTime: body.startTime, startTime: body.startTime,
endTime: body.endTime, endTime: body.endTime,
startLocationAddress: body.startLocationAddress,
startLocationLat:
body.startLocationLat !== null && body.startLocationLat !== undefined
? Number(body.startLocationLat)
: undefined,
startLocationLong:
body.startLocationLong !== null && body.startLocationLong !== undefined
? Number(body.startLocationLong)
: undefined,
endLocationAddress: body.endLocationAddress,
endLocationLat:
body.endLocationLat !== null && body.endLocationLat !== undefined
? Number(body.endLocationLat)
: undefined,
endLocationLong:
body.endLocationLong !== null && body.endLocationLong !== undefined
? Number(body.endLocationLong)
: undefined,
activities: activities.map((activity: any) => { activities: activities.map((activity: any) => {
const itineraryType = const itineraryType =
typeof activity.itineraryType === 'string' typeof activity.itineraryType === 'string'
@@ -188,6 +235,10 @@ export const handler = safeHandler(async (
Number.isNaN(activity.locationLat)) || Number.isNaN(activity.locationLat)) ||
(activity.locationLong !== undefined && (activity.locationLong !== undefined &&
Number.isNaN(activity.locationLong)), Number.isNaN(activity.locationLong)),
Number.isNaN(payload.startLocationLat) ||
Number.isNaN(payload.startLocationLong) ||
Number.isNaN(payload.endLocationLat) ||
Number.isNaN(payload.endLocationLong),
) )
) { ) {
throw new ApiError(400, 'One or more numeric itinerary values are invalid.'); throw new ApiError(400, 'One or more numeric itinerary values are invalid.');

View File

@@ -459,6 +459,12 @@ export class ItineraryService {
endDate: string; endDate: string;
startTime: string; startTime: string;
endTime: string; endTime: string;
startLocationAddress: unknown;
startLocationLat: number;
startLocationLong: number;
endLocationAddress: unknown;
endLocationLat: number;
endLocationLong: number;
activities: Array<{ activities: Array<{
activityXid?: number; activityXid?: number;
venueXid?: number; venueXid?: number;
@@ -540,6 +546,41 @@ export class ItineraryService {
}, },
}); });
const startLocationDetails = await tx.itineraryStartStopDetails.create({
data: {
itineraryHeaderXid: itineraryHeader.id,
itineraryMemberXid: ownerMember.id,
dateValue: itineraryStartDate,
timeValue: payload.startTime,
isStartPoint: true,
locationLat: payload.startLocationLat,
locationLong: payload.startLocationLong,
locationAddress:
payload.startLocationAddress as Prisma.InputJsonValue,
travelMode: null,
kmForNextPoint: null,
timeForNextPointMins: null,
isActive: true,
},
});
const endLocationDetails = await tx.itineraryStartStopDetails.create({
data: {
itineraryHeaderXid: itineraryHeader.id,
itineraryMemberXid: ownerMember.id,
dateValue: itineraryEndDate,
timeValue: payload.endTime,
isStartPoint: false,
locationLat: payload.endLocationLat,
locationLong: payload.endLocationLong,
locationAddress: payload.endLocationAddress as Prisma.InputJsonValue,
travelMode: null,
kmForNextPoint: null,
timeForNextPointMins: null,
isActive: true,
},
});
const createdActivities = await Promise.all( const createdActivities = await Promise.all(
payload.activities.map(async (activityItem) => { payload.activities.map(async (activityItem) => {
const itineraryType = const itineraryType =
@@ -961,6 +1002,8 @@ export class ItineraryService {
memberStatus: ownerMember.memberStatus, memberStatus: ownerMember.memberStatus,
}, },
], ],
startLocationDetails,
endLocationDetails,
activities: createdActivities, activities: createdActivities,
}; };
}); });
@@ -1034,6 +1077,29 @@ export class ItineraryService {
}, },
}, },
}, },
ItineraryStartStopDetails: {
where: {
isActive: true,
deletedAt: null,
},
orderBy: {
createdAt: 'asc',
},
select: {
id: true,
itineraryMemberXid: true,
dateValue: true,
timeValue: true,
isStartPoint: true,
locationLat: true,
locationLong: true,
locationAddress: true,
travelMode: true,
kmForNextPoint: true,
timeForNextPointMins: true,
createdAt: true,
},
},
ItineraryActivities: { ItineraryActivities: {
where: { where: {
isActive: true, isActive: true,
@@ -1482,6 +1548,23 @@ export class ItineraryService {
}), }),
); );
const startStopDetails = itinerary.ItineraryStartStopDetails.map(
(detail) => ({
id: detail.id,
itineraryMemberXid: detail.itineraryMemberXid,
dateValue: detail.dateValue,
timeValue: detail.timeValue,
isStartPoint: detail.isStartPoint,
locationLat: detail.locationLat,
locationLong: detail.locationLong,
locationAddress: detail.locationAddress,
travelMode: detail.travelMode,
kmForNextPoint: detail.kmForNextPoint,
timeForNextPointMins: detail.timeForNextPointMins,
createdAt: detail.createdAt,
}),
);
return { return {
itineraryHeaderXid: itinerary.id, itineraryHeaderXid: itinerary.id,
itineraryNo: itinerary.itineraryNo, itineraryNo: itinerary.itineraryNo,
@@ -1506,6 +1589,7 @@ export class ItineraryService {
membersCount: members.length, membersCount: members.length,
activitiesCount: activities.length, activitiesCount: activities.length,
members, members,
startStopDetails,
activities, activities,
}; };
}), }),