fix(v3.4.6): fix reservation cascade, remove calendar mocks, strip auto meet links, friendly dates, dynamic building floors and career filter
This commit is contained in:
@@ -456,16 +456,53 @@ const handleViewClassroom = async (req, res) => {
|
||||
classroom.code_display = classroom.code_display || classroom.code || `Aula-${classroomId}`;
|
||||
classroom.building_entity = classroom.building_entity || null;
|
||||
|
||||
// Fetch upcoming reservations for this classroom
|
||||
// Fetch upcoming reservations for this classroom (encompassing full 2026 academic term)
|
||||
try {
|
||||
const rRes = await req.apiClient.get(`/reservations?classroom_id=${classroomId}&start_date=2026-08-31&end_date=2026-10-01`);
|
||||
const rRes = await req.apiClient.get(`/reservations?classroom_id=${classroomId}&start_date=2026-08-01&end_date=2026-12-31`);
|
||||
const allClassroomRes = (rRes.data && (rRes.data.reservations || rRes.data)) || [];
|
||||
upcomingReservations = allClassroomRes.map(r => ({
|
||||
...r,
|
||||
date_display: r.start_time ? r.start_time.split('T')[0] : '',
|
||||
start_time_display: r.start_time ? (r.start_time.includes('T') ? r.start_time.split('T')[1].substring(0, 5) : r.start_time) : '',
|
||||
end_time_display: r.end_time ? (r.end_time.includes('T') ? r.end_time.split('T')[1].substring(0, 5) : r.end_time) : ''
|
||||
})).sort((a, b) => a.start_time.localeCompare(b.start_time)).slice(0, 20);
|
||||
const dayNames = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'];
|
||||
|
||||
upcomingReservations = allClassroomRes.map(r => {
|
||||
let dateDisplayFriendly = '';
|
||||
let timeRangeFriendly = '';
|
||||
let fullDisplay = '';
|
||||
|
||||
if (r.start_time) {
|
||||
try {
|
||||
const rawStart = String(r.start_time).replace(' ', 'T');
|
||||
const rawEnd = r.end_time ? String(r.end_time).replace(' ', 'T') : '';
|
||||
const dtStart = new Date(rawStart);
|
||||
const dtEnd = rawEnd ? new Date(rawEnd) : null;
|
||||
|
||||
const dayName = dayNames[dtStart.getDay()];
|
||||
const d = String(dtStart.getDate()).padStart(2, '0');
|
||||
const m = String(dtStart.getMonth() + 1).padStart(2, '0');
|
||||
const y = dtStart.getFullYear();
|
||||
dateDisplayFriendly = `${dayName} ${d}/${m}/${y}`;
|
||||
|
||||
const sH = String(dtStart.getHours()).padStart(2, '0');
|
||||
const sM = String(dtStart.getMinutes()).padStart(2, '0');
|
||||
const eH = dtEnd ? String(dtEnd.getHours()).padStart(2, '0') : '';
|
||||
const eM = dtEnd ? String(dtEnd.getMinutes()).padStart(2, '0') : '';
|
||||
timeRangeFriendly = dtEnd ? `${sH}:${sM} a ${eH}:${eM} hs` : `${sH}:${sM} hs`;
|
||||
fullDisplay = `${dateDisplayFriendly} · ${timeRangeFriendly}`;
|
||||
} catch (e) {
|
||||
dateDisplayFriendly = r.start_time.split('T')[0] || r.start_time;
|
||||
timeRangeFriendly = r.end_time ? `${r.start_time} - ${r.end_time}` : r.start_time;
|
||||
fullDisplay = `${dateDisplayFriendly} · ${timeRangeFriendly}`;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...r,
|
||||
date_display: r.start_time ? r.start_time.split('T')[0] : '',
|
||||
date_display_friendly: dateDisplayFriendly,
|
||||
time_range_friendly: timeRangeFriendly,
|
||||
full_display: fullDisplay,
|
||||
start_time_display: r.start_time ? (r.start_time.includes('T') ? r.start_time.split('T')[1].substring(0, 5) : r.start_time) : '',
|
||||
end_time_display: r.end_time ? (r.end_time.includes('T') ? r.end_time.split('T')[1].substring(0, 5) : r.end_time) : ''
|
||||
};
|
||||
}).sort((a, b) => (a.start_time || '').localeCompare(b.start_time || '')).slice(0, 30);
|
||||
} catch (e) {
|
||||
console.warn('Could not fetch reservations for classroom:', e.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user