sending the lowest price for activity and sending the venue prices
This commit is contained in:
@@ -2243,6 +2243,24 @@ export class ItineraryService {
|
||||
venueName: true,
|
||||
venueLabel: true,
|
||||
venueCapacity: true,
|
||||
ActivityPrices: {
|
||||
where: {
|
||||
isActive: true,
|
||||
deletedAt: null,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: 'asc',
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
noOfSession: true,
|
||||
isPackage: true,
|
||||
sessionValidity: true,
|
||||
sessionValidityFrequency: true,
|
||||
basePrice: true,
|
||||
sellPrice: true,
|
||||
},
|
||||
},
|
||||
ActivityVenueArtifacts: {
|
||||
where: {
|
||||
isActive: true,
|
||||
@@ -2419,6 +2437,7 @@ export class ItineraryService {
|
||||
venueXid: venue.id,
|
||||
venueName: venue.venueName,
|
||||
venueLabel: venue.venueLabel,
|
||||
activityPrices: venue.ActivityPrices,
|
||||
mediaFileName: venue.ActivityVenueArtifacts[0]?.mediaFileName ?? null,
|
||||
mediaType: venue.ActivityVenueArtifacts[0]?.mediaType ?? null,
|
||||
venueCapacity: venue.venueCapacity,
|
||||
@@ -2466,12 +2485,64 @@ export class ItineraryService {
|
||||
new Date(second!.startDateTime).getTime(),
|
||||
);
|
||||
|
||||
const venuePriceDetails = activity.ActivityVenues.map((venue) => {
|
||||
const prices = venue.ActivityPrices.map((price) => ({
|
||||
id: price.id,
|
||||
noOfSession: price.noOfSession,
|
||||
isPackage: price.isPackage,
|
||||
sessionValidity: price.sessionValidity,
|
||||
sessionValidityFrequency: price.sessionValidityFrequency,
|
||||
basePrice: price.basePrice,
|
||||
sellPrice: price.sellPrice,
|
||||
}));
|
||||
|
||||
const lowestPrice = venue.ActivityPrices.reduce(
|
||||
(lowest, current) =>
|
||||
!lowest || current.sellPrice < lowest.sellPrice ? current : lowest,
|
||||
null as (typeof venue.ActivityPrices)[number] | null,
|
||||
);
|
||||
|
||||
return {
|
||||
venueXid: venue.id,
|
||||
venueName: venue.venueName,
|
||||
venueLabel: venue.venueLabel,
|
||||
venueCapacity: venue.venueCapacity,
|
||||
availableSeats: venue.availableSeats,
|
||||
activityPrice: lowestPrice?.sellPrice ?? null,
|
||||
activityBasePrice: lowestPrice?.basePrice ?? null,
|
||||
activityPriceDetails: lowestPrice,
|
||||
prices,
|
||||
};
|
||||
});
|
||||
|
||||
const lowestPriceVenue = venuePriceDetails.reduce(
|
||||
(lowest, current) => {
|
||||
if (!lowest) {
|
||||
return current;
|
||||
}
|
||||
|
||||
if (lowest.activityPrice === null) {
|
||||
return current;
|
||||
}
|
||||
|
||||
if (current.activityPrice === null) {
|
||||
return lowest;
|
||||
}
|
||||
|
||||
return current.activityPrice < lowest.activityPrice ? current : lowest;
|
||||
},
|
||||
null as (typeof venuePriceDetails)[number] | null,
|
||||
);
|
||||
|
||||
const coverImage =
|
||||
activity.ActivitiesMedia.find((media) => media.isCoverImage) ??
|
||||
activity.ActivitiesMedia[0] ??
|
||||
null;
|
||||
|
||||
const energyLevel = activity.activityType?.energyLevel ?? null;
|
||||
const lowestActivityPrice = lowestPriceVenue?.activityPrice ?? null;
|
||||
const lowestActivityBasePrice = lowestPriceVenue?.activityBasePrice ?? null;
|
||||
const lowestActivityPriceDetails = lowestPriceVenue?.activityPriceDetails ?? null;
|
||||
|
||||
return {
|
||||
userBucketInterestedXid: entry.id,
|
||||
@@ -2479,6 +2550,12 @@ export class ItineraryService {
|
||||
isBucket: entry.isBucket,
|
||||
bucketTypeName: entry.bucketTypeName,
|
||||
distance,
|
||||
activityPrice: lowestActivityPrice,
|
||||
activityBasePrice: lowestActivityBasePrice,
|
||||
activityPriceDetails: lowestActivityPriceDetails,
|
||||
lowestActivityPrice,
|
||||
lowestActivityBasePrice,
|
||||
lowestActivityPriceDetails,
|
||||
activityTitle: activity.activityTitle,
|
||||
activityDescription: activity.activityDescription,
|
||||
activityDurationMins,
|
||||
@@ -2486,13 +2563,19 @@ export class ItineraryService {
|
||||
activityCoverImagePresignedUrl: await attachPresignedUrl(
|
||||
coverImage?.mediaFileName,
|
||||
),
|
||||
venue: availableSlotsWithPresignedUrl[0]
|
||||
venue: lowestPriceVenue
|
||||
? {
|
||||
venueXid: availableSlotsWithPresignedUrl[0].venueXid,
|
||||
venueName: availableSlotsWithPresignedUrl[0].venueName,
|
||||
venueLabel: availableSlotsWithPresignedUrl[0].venueLabel,
|
||||
venueXid: lowestPriceVenue.venueXid,
|
||||
venueName: lowestPriceVenue.venueName,
|
||||
venueLabel: lowestPriceVenue.venueLabel,
|
||||
venueCapacity: lowestPriceVenue.venueCapacity,
|
||||
availableSeats: lowestPriceVenue.availableSeats,
|
||||
activityPrice: lowestPriceVenue.activityPrice,
|
||||
activityBasePrice: lowestPriceVenue.activityBasePrice,
|
||||
activityPriceDetails: lowestPriceVenue.activityPriceDetails,
|
||||
}
|
||||
: null,
|
||||
venuePrices: venuePriceDetails,
|
||||
availableSlots: availableSlotsWithPresignedUrl,
|
||||
entryType: activity.ActivityAllowedEntry[0]?.allowedEntryType ?? null,
|
||||
energyLevel: energyLevel
|
||||
@@ -2641,6 +2724,7 @@ export class ItineraryService {
|
||||
hasPreviousPage: sanitizedPage > 1 && totalPages > 0,
|
||||
},
|
||||
count: paginatedActivities.length,
|
||||
activityCount: totalCount,
|
||||
totalCount,
|
||||
activities: paginatedActivities,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user