small chagnes

This commit is contained in:
paritosh18
2026-02-09 15:50:56 +05:30
parent 1dcce8084c
commit 68facd1146
2 changed files with 26 additions and 33 deletions

View File

@@ -49,11 +49,24 @@ export const handler = safeHandler(async (
// Shape response to match UI: only include fields shown in image
const activity = activityDetails.activity;
// Rooms: combine ActivityVenues with schedule info per venue
// Rooms: combine ActivityVenues with their respective slots for the selected date
const Venues = (activity.ActivityVenues || []).map((v: any) => {
// find schedule header for this venue
const header = scheduleDetails.find((h: any) => h.activityVenue?.venueXid === v.id);
const slotCount = header ? (header.slots || []).length : 0;
const roomSlots = (header?.slots || []).map((s: any) => {
let status = 'Available';
if (s.maxCapacity === 0) status = 'Housefull';
else if (s.maxCapacity <= 2) status = '2 Slots Left';
else if (s.maxCapacity <= 5) status = 'Fast Filling';
return {
slotId: s.slotId,
startTime: s.startTime,
endTime: s.endTime,
status,
maxCapacity: s.maxCapacity,
};
});
return {
venueXid: v.id,
@@ -62,41 +75,21 @@ export const handler = safeHandler(async (
venueCapacity: v.venueCapacity,
availableSeats: v.availableSeats ?? null,
price: v.ActivityPrices?.[0]?.sellPrice ?? null,
slotsCount: slotCount,
slots: roomSlots,
slotsCount: roomSlots.length,
};
});
// Slots: aggregate slots across scheduleDetails
const slots: any[] = [];
for (const h of scheduleDetails) {
for (const s of h.slots || []) {
// status heuristic based on maxCapacity
let status = 'Available';
if (s.maxCapacity === 0) status = 'Housefull';
else if (s.maxCapacity <= 2) status = '2 Slots Left';
else if (s.maxCapacity <= 5) status = 'Fast Filling';
slots.push({
slotId: s.slotId,
startTime: s.startTime,
endTime: s.endTime,
status,
maxCapacity: s.maxCapacity,
venueXid: h.activityVenue?.venueXid,
});
}
}
// derive check-in/out from slot times (earliest start, latest end)
const startTimes = slots.map(s => s.startTime).filter(Boolean);
const endTimes = slots.map(s => s.endTime).filter(Boolean);
// derive check-in/out from all room slots (earliest start, latest end)
const allSlots = rooms.flatMap(r => r.slots || []);
const startTimes = allSlots.map(s => s.startTime).filter(Boolean);
const endTimes = allSlots.map(s => s.endTime).filter(Boolean);
const checkInTime = startTimes.length ? startTimes.sort()[0] : null;
const checkOutTime = endTimes.length ? endTimes.sort().reverse()[0] : null;
const responsePayload = {
selectedDate,
Venues,
slots,
checkInTime,
checkOutTime,
};

View File

@@ -1,13 +1,12 @@
import { Injectable } from '@nestjs/common';
import { PrismaClient, User, UserAddressDetails } from '@prisma/client';
import ApiError from '../../../common/utils/helper/ApiError';
import * as bcrypt from 'bcryptjs';
import { UserPersonalInfoSchema } from '../../../common/utils/validation/user/addPersonalInfo.validation';
import { ACTIVITY_AM_INTERNAL_STATUS, ACTIVITY_INTERNAL_STATUS } from '../../../common/utils/constants/host.constant';
import { getPresignedUrl } from '../../../common/middlewares/aws/getPreSignedUrl';
import { ACTIVITY_AM_INTERNAL_STATUS, ACTIVITY_INTERNAL_STATUS } from '../../../common/utils/constants/host.constant';
import ApiError from '../../../common/utils/helper/ApiError';
import { UserPersonalInfoSchema } from '../../../common/utils/validation/user/addPersonalInfo.validation';
import config from '@/config/config';
import { isNotIn } from 'class-validator';
// function deg2rad(deg) {
// return deg * (Math.PI / 180);
// }
@@ -1387,6 +1386,7 @@ export class UserService {
isActive: true
},
select: {
id: true,
venueName: true,
venueLabel: true,
venueCapacity: true,