fix(v3.4.7): fix syntax in buildings.js route handler
This commit is contained in:
@@ -152,34 +152,6 @@ router.post(['/add', '/add_building'], async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 3. View Building
|
||||
router.get(['/view/:id', '/view_building', '/:id'], async (req, res) => {
|
||||
const id = parseInt(req.params.id || req.query.id, 10) || 1;
|
||||
let building = null;
|
||||
let classrooms = [];
|
||||
|
||||
try {
|
||||
const apiRes = await req.apiClient.get(`/buildings/${id}`);
|
||||
if (apiRes.data && apiRes.data.building) {
|
||||
building = apiRes.data.building;
|
||||
classrooms = apiRes.data.classrooms || [];
|
||||
}
|
||||
} catch (e) {
|
||||
building = defaultBuildings.find(b => b.id === id) || defaultBuildings[0];
|
||||
}
|
||||
|
||||
if (!building) {
|
||||
return res.redirect('/buildings/list_buildings');
|
||||
}
|
||||
|
||||
const is_virtual = Boolean(building.is_virtual || (building.code && building.code.toUpperCase() === 'VIRTUAL') || (building.name && building.name.toUpperCase().includes('VIRTUAL')));
|
||||
building = {
|
||||
...building,
|
||||
is_virtual,
|
||||
capacity_display: is_virtual ? 'Ilimitada (Virtual)' : String(building.physical_capacity || building.total_capacity || 0),
|
||||
floors_display: is_virtual ? 'Digital' : String(building.floors ?? 1)
|
||||
};
|
||||
|
||||
// Función auxiliar para agrupar y sintetizar los pisos / niveles físicos y sus aulas
|
||||
const buildFloorsList = (building, classrooms = []) => {
|
||||
const is_virtual = Boolean(building.is_virtual || (building.code && building.code.toUpperCase() === 'VIRTUAL') || (building.name && building.name.toUpperCase().includes('VIRTUAL')));
|
||||
|
||||
Reference in New Issue
Block a user