refactor(dateTime): streamline slot handling and improve session management
This commit is contained in:
+11
-13
@@ -1,19 +1,17 @@
|
||||
const MORNING_END = "12:00";
|
||||
|
||||
export function adaptSlots(slotsResponse) {
|
||||
const sessions = slotsResponse?.data?.sessions ?? slotsResponse?.sessions ?? [];
|
||||
|
||||
const morning = [];
|
||||
const evening = [];
|
||||
|
||||
sessions.forEach((session) => {
|
||||
(session.slots ?? []).forEach((slot) => {
|
||||
const target = slot.start_time < MORNING_END ? morning : evening;
|
||||
target.push(slot);
|
||||
});
|
||||
});
|
||||
|
||||
return { morning, evening };
|
||||
// Group slots by the shifts the backend already returns; the front does not
|
||||
// decide shift boundaries (no hard-coded morning/evening split). Each session
|
||||
// becomes one tab labelled with its own time range.
|
||||
return sessions
|
||||
.filter((session) => Array.isArray(session.slots) && session.slots.length > 0)
|
||||
.map((session) => ({
|
||||
start_time: session.start_time,
|
||||
end_time: session.end_time,
|
||||
label: `${session.start_time} - ${session.end_time}`,
|
||||
slots: session.slots,
|
||||
}));
|
||||
}
|
||||
|
||||
export function hasAvailable(slots) {
|
||||
|
||||
Reference in New Issue
Block a user