Files
pulse-signage/src/web/routes/data-sources/timetables/list.js
T
2026-08-03 12:45:27 +01:00

32 lines
1.0 KiB
JavaScript

// Timetable group list page renderer.
const { renderView } = require('../../../view');
function formatNextStartLabel(value, formatDashboardDate) {
if (!value) {
return 'No entries';
}
const label = typeof formatDashboardDate === 'function'
? formatDashboardDate(value)
: String(value);
return label || 'No entries';
}
module.exports = function renderTimetableGroupsPage(data, message, currentUser, formatDashboardDate) {
const timetableGroups = (data.timetableGroups || []).map(function (timetableGroup) {
return Object.assign({}, timetableGroup, {
nextStartLabel: formatNextStartLabel(timetableGroup.next_start_datetime, formatDashboardDate),
nextStartValue: timetableGroup.next_start_datetime ? new Date(timetableGroup.next_start_datetime).toISOString() : ''
});
});
return renderView('data-sources/timetables/list', {
title: 'Timetables',
active: 'timetables',
message: message,
currentUser: currentUser || null,
timetableGroups: timetableGroups,
pagination: data.pagination || null
});
};