feat: sync GridSmart agendas and use event-relative demo time
Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage. Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
f32289f583
commit
84691de6ee
27 files changed
+1215
-60
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { Session, Slot } from './types';
|
||||
|
||||
type AgendaBlock = { slot: Slot; sessions: Session[] };
|
||||
|
||||
export function mergeAgendaPlaceholders(slots: AgendaBlock[]): AgendaBlock[] {
|
||||
const blocks = slots.map(block => ({ slot: block.slot, sessions: [...block.sessions] }));
|
||||
const merged = new Set<number>();
|
||||
for (const block of blocks) {
|
||||
if (block.slot.type !== 'service_session') continue;
|
||||
const target = blocks.find(candidate => candidate.slot.type === 'session'
|
||||
&& candidate.slot.slot_date === block.slot.slot_date
|
||||
&& candidate.slot.start_time === block.slot.start_time
|
||||
&& candidate.slot.end_time === block.slot.end_time);
|
||||
if (!target) continue;
|
||||
const placeholders = block.sessions.filter(session => session.slot_type === 'service_session'
|
||||
&& session.title.trim().toLowerCase() === 'placeholder');
|
||||
if (!placeholders.length) continue;
|
||||
target.sessions.push(...placeholders);
|
||||
const transferred = new Set(placeholders.map(session => session.id));
|
||||
block.sessions = block.sessions.filter(session => !transferred.has(session.id));
|
||||
if (!block.sessions.length) merged.add(block.slot.id);
|
||||
}
|
||||
return blocks.filter(block => !merged.has(block.slot.id));
|
||||
}
|
||||
@@ -83,7 +83,11 @@ export function groupAgenda(rows: AgendaRow[]): { slot: Slot; sessions: Session[
|
||||
});
|
||||
}
|
||||
}
|
||||
return [...map.values()].sort((a, b) => a.slot.id - b.slot.id);
|
||||
return [...map.values()].sort((first, second) =>
|
||||
first.slot.slot_date.localeCompare(second.slot.slot_date)
|
||||
|| first.slot.start_time.localeCompare(second.slot.start_time)
|
||||
|| first.slot.end_time.localeCompare(second.slot.end_time)
|
||||
|| first.slot.id - second.slot.id);
|
||||
}
|
||||
|
||||
/** Submit (or update) the current user's event-level feedback. */
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import type { Slot } from './types';
|
||||
|
||||
/** The event day (from the seed). All slot times are on this date. */
|
||||
export const EVENT_DATE = '2026-02-20';
|
||||
|
||||
/** Simulated "now" used for the demo (10:20 on event day → Slot 2 is live,
|
||||
* Slot 3 is next). Matches the mockup's "Good morning" greeting. */
|
||||
export const DEFAULT_NOW = new Date(`${EVENT_DATE}T10:20:00`);
|
||||
export function demoNow(eventDate: string): Date {
|
||||
return new Date(`${eventDate}T10:20:00`);
|
||||
}
|
||||
|
||||
export type SlotStatus = 'done' | 'now' | 'next';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { getActiveEvent, getAgenda, groupAgenda } from './api';
|
||||
import { DEFAULT_NOW } from './time';
|
||||
import { demoNow } from './time';
|
||||
import type { Event, Session, Slot } from './types';
|
||||
|
||||
export interface EventData {
|
||||
@@ -53,7 +53,7 @@ export function useEvent(): EventData {
|
||||
// The event's `use_realtime_clock` flag decides the clock: the real system
|
||||
// time, or the simulated mid-event clock (so the demo always looks live).
|
||||
const clockMode: 'simulated' | 'realtime' = event?.use_realtime_clock ? 'realtime' : 'simulated';
|
||||
const now = clockMode === 'realtime' ? new Date() : DEFAULT_NOW;
|
||||
const now = clockMode === 'simulated' && event ? demoNow(event.start_date) : new Date();
|
||||
|
||||
return {
|
||||
event,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useEvent } from '../lib/useEvent';
|
||||
import { mergeAgendaPlaceholders } from '../lib/agendaBlocks';
|
||||
import {
|
||||
clearPreference,
|
||||
getMyCheckins,
|
||||
@@ -48,6 +49,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
|
||||
const matchesFilter = (s: Session) =>
|
||||
(!levelFilter || s.level === levelFilter) && (!areaFilter || s.area === areaFilter);
|
||||
const displayBlocks = mergeAgendaPlaceholders(slots);
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
@@ -159,7 +161,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
<div className="h1">Agenda</div>
|
||||
<div className="muted small">{event.name}</div>
|
||||
</div>
|
||||
<span className="pill violet">{slots.length} slots</span>
|
||||
<span className="pill violet">{displayBlocks.length} slots</span>
|
||||
</div>
|
||||
<div className="muted small" style={{ marginTop: -4 }}>
|
||||
Pick <b>one session per slot</b> — you can change until the slot starts.
|
||||
@@ -209,14 +211,12 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
{slots.map(({ slot, sessions }) => {
|
||||
{displayBlocks.map(({ slot, sessions }) => {
|
||||
const status = slotStatus(slot, now);
|
||||
const isServiceSlot = slot.type === 'service_session';
|
||||
// Apply the level/area filter to non-service sessions only (service
|
||||
// sessions have no level/area and are always shown).
|
||||
const visibleSessions = isServiceSlot
|
||||
? sessions
|
||||
: sessions.filter(matchesFilter);
|
||||
const visibleSessions = sessions.filter(session => session.slot_type === 'service_session' || matchesFilter(session));
|
||||
// Skip the slot if it's a talk slot and all its sessions are filtered out.
|
||||
if (!isServiceSlot && visibleSessions.length === 0) return null;
|
||||
return (
|
||||
@@ -235,7 +235,7 @@ export function Agenda({ openFeedback }: { openFeedback: (sessionId: string) =>
|
||||
{visibleSessions.map((s) => {
|
||||
const picked = pickFor(slot.id) === s.id;
|
||||
const isMySession = mySpeakerSessions.includes(s.id);
|
||||
const isService = slot.type === 'service_session';
|
||||
const isService = s.slot_type === 'service_session';
|
||||
return (
|
||||
<button key={s.id} className={`sess ${picked ? 'picked' : ''}`} onClick={() => setSelected(s)}>
|
||||
<div className="grow">
|
||||
|
||||
Reference in new issue
Block a user