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.
This commit is contained in:
1 parent
40f24cf5f7
commit
c0fbf495dc
27 files changed
+1215
-60
No files matched your search
@@ -0,0 +1,19 @@
|
||||
export function normalizeSessionizeSource(value: string): string | null {
|
||||
let source = value.trim();
|
||||
if (!source) return null;
|
||||
if (source.startsWith('<')) {
|
||||
const document = new DOMParser().parseFromString(source, 'text/html');
|
||||
const scripts = document.querySelectorAll('script[src]');
|
||||
if (scripts.length !== 1) throw new Error('Paste one Sessionize script tag or URL');
|
||||
source = scripts[0].getAttribute('src') || '';
|
||||
}
|
||||
let url: URL;
|
||||
try { url = new URL(source); } catch { throw new Error('Enter a valid Sessionize URL or script tag'); }
|
||||
if (url.protocol !== 'https:' || url.hostname !== 'sessionize.com' || url.port
|
||||
|| url.username || url.password || !/^\/api\/v2\/[a-z0-9]+\/view\/(All|GridSmart)$/i.test(url.pathname)) {
|
||||
throw new Error('Use a Sessionize HTTPS All or GridSmart endpoint');
|
||||
}
|
||||
url.search = '';
|
||||
url.hash = '';
|
||||
return url.href;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import type { Event, PretixOptions, PretixSyncResult, SyncResult } from '../lib/types';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
import { Empty, Modal, Spinner, Toggle } from '../components/ui';
|
||||
import { normalizeSessionizeSource } from '../lib/sessionizeSource';
|
||||
|
||||
export function Events() {
|
||||
const { push } = useToast();
|
||||
@@ -286,6 +287,7 @@ function EventModal({
|
||||
const [endDate, setEndDate] = useState(event ? event.end_date.slice(0, 10) : '');
|
||||
const [location, setLocation] = useState(event?.location ?? '');
|
||||
const [endpoint, setEndpoint] = useState(event?.sessionize_endpoint ?? '');
|
||||
const [endpointError, setEndpointError] = useState<string | null>(null);
|
||||
const [pretixApiKey, setPretixApiKey] = useState(event?.pretix_api_key ?? '');
|
||||
const [pretixOrganizer, setPretixOrganizer] = useState(event?.pretix_organizer ?? '');
|
||||
const [pretixEventSlug, setPretixEventSlug] = useState(event?.pretix_event_slug ?? '');
|
||||
@@ -328,6 +330,14 @@ function EventModal({
|
||||
|
||||
async function save() {
|
||||
if (!name.trim() || !startDate || !endDate) return;
|
||||
let source: string | null;
|
||||
try {
|
||||
source = normalizeSessionizeSource(endpoint);
|
||||
setEndpointError(null);
|
||||
} catch (error) {
|
||||
setEndpointError(error instanceof Error ? error.message : 'Invalid Sessionize source');
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
try {
|
||||
await upsertEvent(event?.id ?? null, {
|
||||
@@ -335,7 +345,7 @@ function EventModal({
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
location: location.trim() || null,
|
||||
sessionize_endpoint: endpoint.trim() || null,
|
||||
sessionize_endpoint: source,
|
||||
pretix_organizer: pretixOrganizer.trim() || null,
|
||||
pretix_event_slug: pretixEventSlug.trim() || null,
|
||||
pretix_api_key: pretixApiKey.trim() || null,
|
||||
@@ -391,16 +401,20 @@ function EventModal({
|
||||
{endpoint.trim() ? <span className="pill green">configured</span> : <span className="pill">not set</span>}
|
||||
</div>
|
||||
<div className="field">
|
||||
<label>Sessionize endpoint</label>
|
||||
<input
|
||||
<label htmlFor="sessionize-source">Sessionize endpoint</label>
|
||||
<textarea
|
||||
id="sessionize-source"
|
||||
className="input"
|
||||
rows={3}
|
||||
value={endpoint}
|
||||
onChange={(e) => setEndpoint(e.target.value)}
|
||||
placeholder="https://sessionize.com/api/v2/<id>/view/All"
|
||||
onChange={(e) => { setEndpoint(e.target.value); setEndpointError(null); }}
|
||||
aria-invalid={!!endpointError}
|
||||
aria-describedby={endpointError ? 'sessionize-source-error' : undefined}
|
||||
placeholder="https://sessionize.com/api/v2/<id>/view/GridSmart"
|
||||
/>
|
||||
{endpointError && <div id="sessionize-source-error" role="alert" className="error">{endpointError}</div>}
|
||||
<div className="muted small" style={{ marginTop: 4 }}>
|
||||
The Sessionize API URL (e.g. <code>…/api/v2/<id>/view/All</code>). Used by the
|
||||
“Run sync” button. You can also import the .xlsx export in the Interfaces menu.
|
||||
All / GridSmart URL or Sessionize script tag. Active events sync automatically every 15 minutes.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user