@burdenoff/microfe-eventfullymanaged 2026.1124.2 → 2026.1124.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eventfullymanaged/components/AiOperationsPanel.d.ts +10 -0
- package/dist/eventfullymanaged/components/AiOperationsPanel.js +560 -0
- package/dist/eventfullymanaged/components/AiOperationsPanel.js.map +1 -0
- package/dist/eventfullymanaged/components/AttendanceForecast.js +62 -39
- package/dist/eventfullymanaged/components/AttendanceForecast.js.map +1 -1
- package/dist/eventfullymanaged/pages/certificates/CertificateEmailControls.d.ts +6 -0
- package/dist/eventfullymanaged/pages/certificates/CertificateEmailControls.js +141 -0
- package/dist/eventfullymanaged/pages/certificates/CertificateEmailControls.js.map +1 -0
- package/dist/eventfullymanaged/pages/certificates/CertificateIssuance.js +121 -100
- package/dist/eventfullymanaged/pages/certificates/CertificateIssuance.js.map +1 -1
- package/dist/eventfullymanaged/pages/certificates/CertificateReceiptSearch.d.ts +8 -0
- package/dist/eventfullymanaged/pages/certificates/CertificateReceiptSearch.js +43 -0
- package/dist/eventfullymanaged/pages/certificates/CertificateReceiptSearch.js.map +1 -0
- package/dist/eventfullymanaged/pages/certificates/CertificateScheduleDialog.js +20 -10
- package/dist/eventfullymanaged/pages/certificates/CertificateScheduleDialog.js.map +1 -1
- package/dist/eventfullymanaged/pages/modules/AnalyticsPage.js +109 -107
- package/dist/eventfullymanaged/pages/modules/AnalyticsPage.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +648 -0
- package/dist/generated/wspace-operations.js +374 -37
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +396 -2
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js +23 -0
- package/dist/node_modules/@apollo/client/errors/CombinedGraphQLErrors.js.map +1 -0
- package/dist/node_modules/@apollo/client/errors/utils.js +15 -0
- package/dist/node_modules/@apollo/client/errors/utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiOperationsPanel.js","names":["_Fragment","asRecord","value","readNarrative","rec","\"text\"","\"provider\"","\"model\"","readNoShows","root","raw","\"result\"","\"eventId\"","\"eventNoShowRate\"","sessions","\"sessions\"","\"confidence\"","\"coldStart\"","\"coldStartReason\"","\"narrative\"","readRightSizing","\"recommendations\"","readConflicts","\"conflicts\"","formatDateTime","parsed","formatMicroUsd","micro","usd","ProvenanceLine","formattedTime","generatedAt","effectiveModel","narrative","model","effectiveProvider","provider","label","Fragment","ConfirmApplyBar","pending","Button","applying","onConfirm","onCancel","EventDecisionSuite","client","useApolloClient","pendingApply","setPendingApply","useState","actionError","setActionError","savedNoShows","useEventfullymanagedSavedNoShowPredictionQuery","savedRightSize","useEventfullymanagedSavedCapacityRightSizingQuery","savedConflicts","useEventfullymanagedSavedAgendaConflictsQuery","runNoShows","noShowsState","useEventfullymanagedPredictNoShowsMutation","runRightSize","rightSizeState","useEventfullymanagedRightSizeSessionsMutation","runConflicts","conflictsState","useEventfullymanagedResolveAgendaConflictsMutation","applyAgendaFix","applyState","useEventfullymanagedApplyAgendaFixMutation","noShows","rightSize","conflicts","onRunAll","notify","error","describeError","onConfirmApply","response","running","Sparkles","UserX","Badge","session","Scale","AlertTriangle","CheckCircle2","conflict","index","AiActivityAndCreditsStrip","windowBounds","to","creditsQuery","useEventfullymanagedAiCreditStatusQuery","historyQuery","useEventfullymanagedAiInvocationHistoryQuery","credits","rows","useMemo","telemetryUnavailable","Coins","ExternalLink","Activity","row","AiOperationsPanel","selected","setSelected","eventId","events","event","GlassCard","Select","SelectTrigger","SelectValue","SelectContent","SelectItem"],"sources":["../../../src/eventfullymanaged/components/AiOperationsPanel.tsx"],"sourcesContent":["import { useApolloClient } from '@apollo/client/react';\nimport { Activity, AlertTriangle, CheckCircle2, Coins, ExternalLink, Scale, Sparkles, UserX } from 'lucide-react';\nimport { useMemo, useState } from 'react';\nimport {\n Badge,\n Button,\n GlassCard,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n useEventfullymanagedAiCreditStatusQuery,\n useEventfullymanagedAiInvocationHistoryQuery,\n useEventfullymanagedApplyAgendaFixMutation,\n useEventfullymanagedPredictNoShowsMutation,\n useEventfullymanagedResolveAgendaConflictsMutation,\n useEventfullymanagedRightSizeSessionsMutation,\n useEventfullymanagedSavedAgendaConflictsQuery,\n useEventfullymanagedSavedCapacityRightSizingQuery,\n useEventfullymanagedSavedNoShowPredictionQuery,\n} from '../../generated/wspace-operations';\nimport type { EventGql } from '../api/eventApi';\nimport { describeError } from '../lib/mutationResult';\nimport { notify } from '../lib/toast';\n\ntype NarrativeView = {\n text: string;\n provider: string;\n model: string;\n};\n\ntype SessionNoShowView = {\n sessionId: string;\n title: string;\n expectedDemand: number;\n predictedAttendance: number;\n predictedNoShowRate: number;\n drivers: string[];\n};\n\ntype NoShowDecisionView = {\n eventId: string;\n confidence: string;\n coldStart: boolean;\n coldStartReason?: string | null;\n eventNoShowRate: number;\n sessions: SessionNoShowView[];\n narrative?: NarrativeView | null;\n};\n\ntype CapacityRecommendationView = {\n sessionId: string;\n title: string;\n action: string;\n predictedAttendance: number;\n high: number;\n effectiveCapacity?: number | null;\n targetVenueId?: string | null;\n targetVenueName?: string | null;\n targetCapacity?: number | null;\n rationale: string;\n applyable: boolean;\n};\n\ntype RightSizeDecisionView = {\n eventId: string;\n confidence: string;\n coldStart: boolean;\n recommendations: CapacityRecommendationView[];\n narrative?: NarrativeView | null;\n};\n\ntype AgendaFixView = {\n action: string;\n sessionId: string;\n targetVenueId?: string | null;\n targetVenueName?: string | null;\n targetStartsAt?: string | null;\n targetEndsAt?: string | null;\n targetCapacity?: number | null;\n rationale: string;\n applyable: boolean;\n};\n\ntype AgendaConflictView = {\n type: string;\n sessionAId: string;\n sessionATitle: string;\n sessionBTitle?: string | null;\n message: string;\n suggestedFix: AgendaFixView;\n};\n\ntype ConflictsDecisionView = {\n eventId: string;\n conflicts: AgendaConflictView[];\n narrative?: NarrativeView | null;\n};\n\ntype PendingApply = {\n sessionId: string;\n sessionTitle: string;\n summary: string;\n venueId?: string | null;\n startsAt?: string | null;\n endsAt?: string | null;\n capacity?: number | null;\n};\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : null;\n}\n\nfunction readNarrative(value: unknown): NarrativeView | null {\n const rec = asRecord(value);\n if (!rec) return null;\n if (typeof rec['text'] !== 'string' || !rec['text'].trim()) return null;\n if (typeof rec['provider'] !== 'string' || typeof rec['model'] !== 'string') return null;\n return { text: rec['text'], provider: rec['provider'], model: rec['model'] };\n}\n\nfunction readNoShows(raw: unknown): NoShowDecisionView | null {\n const root = asRecord(raw);\n const rec = asRecord(root?.['result']) ?? root;\n if (!rec || typeof rec['eventId'] !== 'string' || typeof rec['eventNoShowRate'] !== 'number') return null;\n const sessions = Array.isArray(rec['sessions']) ? (rec['sessions'] as SessionNoShowView[]) : [];\n return {\n eventId: rec['eventId'],\n confidence: typeof rec['confidence'] === 'string' ? rec['confidence'] : 'LOW',\n coldStart: Boolean(rec['coldStart']),\n coldStartReason: typeof rec['coldStartReason'] === 'string' ? rec['coldStartReason'] : null,\n eventNoShowRate: rec['eventNoShowRate'],\n sessions,\n narrative: readNarrative(rec['narrative']) ?? readNarrative(root?.['narrative']),\n };\n}\n\nfunction readRightSizing(raw: unknown): RightSizeDecisionView | null {\n const root = asRecord(raw);\n const rec = asRecord(root?.['result']) ?? root;\n if (!rec || typeof rec['eventId'] !== 'string' || !Array.isArray(rec['recommendations'])) return null;\n return {\n eventId: rec['eventId'],\n confidence: typeof rec['confidence'] === 'string' ? rec['confidence'] : 'LOW',\n coldStart: Boolean(rec['coldStart']),\n recommendations: rec['recommendations'] as CapacityRecommendationView[],\n narrative: readNarrative(rec['narrative']) ?? readNarrative(root?.['narrative']),\n };\n}\n\nfunction readConflicts(raw: unknown): ConflictsDecisionView | null {\n const root = asRecord(raw);\n const rec = asRecord(root?.['result']) ?? root;\n if (!rec || typeof rec['eventId'] !== 'string' || !Array.isArray(rec['conflicts'])) return null;\n return {\n eventId: rec['eventId'],\n conflicts: rec['conflicts'] as AgendaConflictView[],\n narrative: readNarrative(rec['narrative']) ?? readNarrative(root?.['narrative']),\n };\n}\n\nfunction formatDateTime(value?: string | null): string | null {\n if (!value) return null;\n const parsed = new Date(value);\n return Number.isNaN(parsed.getTime()) ? null : parsed.toLocaleString();\n}\n\nfunction formatMicroUsd(raw?: string | null): string {\n if (!raw) return '—';\n const micro = Number(raw);\n if (!Number.isFinite(micro)) return '—';\n const usd = micro / 1_000_000;\n return usd < 0.01 && usd > 0 ? `$${usd.toFixed(6)}` : `$${usd.toFixed(4)}`;\n}\n\nfunction ProvenanceLine({\n provider,\n model,\n generatedAt,\n narrative,\n}: {\n provider?: string | null;\n model?: string | null;\n generatedAt?: string | null;\n narrative?: NarrativeView | null;\n}) {\n const formattedTime = formatDateTime(generatedAt);\n const effectiveModel = narrative?.model ?? model;\n const effectiveProvider = narrative?.provider ?? provider;\n const label =\n effectiveModel && effectiveProvider && !effectiveModel.includes('/')\n ? `${effectiveProvider}/${effectiveModel}`\n : (effectiveModel ?? effectiveProvider);\n return (\n <p className=\"text-xs text-text-muted\">\n {label ? <>Model: {label}</> : null}\n {label && formattedTime ? ' · ' : null}\n {formattedTime ? <>Generated {formattedTime}</> : null}\n </p>\n );\n}\n\nfunction ConfirmApplyBar({\n pending,\n applying,\n onConfirm,\n onCancel,\n}: {\n pending: PendingApply;\n applying: boolean;\n onConfirm: () => void;\n onCancel: () => void;\n}) {\n return (\n <div\n role=\"dialog\"\n aria-label=\"Confirm session change\"\n className=\"space-y-2 rounded-md border border-border-seam bg-bg-sunken p-3\"\n >\n <p className=\"text-sm font-semibold text-text-primary\">Confirm change to {pending.sessionTitle}</p>\n <p className=\"text-sm text-text-secondary\">{pending.summary}</p>\n <p className=\"text-xs text-text-muted\">\n Reversible: this updates only this session and can be reverted anytime from the session editor.\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button type=\"button\" size=\"sm\" disabled={applying} onClick={onConfirm}>\n {applying ? 'Applying…' : 'Confirm & apply'}\n </Button>\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" disabled={applying} onClick={onCancel}>\n Cancel\n </Button>\n </div>\n </div>\n );\n}\n\nfunction EventDecisionSuite({ eventId }: { eventId: string }) {\n const client = useApolloClient();\n const [pendingApply, setPendingApply] = useState<PendingApply | null>(null);\n const [actionError, setActionError] = useState<string | null>(null);\n\n const savedNoShows = useEventfullymanagedSavedNoShowPredictionQuery({\n variables: { eventId },\n fetchPolicy: 'network-only',\n });\n const savedRightSize = useEventfullymanagedSavedCapacityRightSizingQuery({\n variables: { eventId },\n fetchPolicy: 'network-only',\n });\n const savedConflicts = useEventfullymanagedSavedAgendaConflictsQuery({\n variables: { eventId },\n fetchPolicy: 'network-only',\n });\n\n const [runNoShows, noShowsState] = useEventfullymanagedPredictNoShowsMutation();\n const [runRightSize, rightSizeState] = useEventfullymanagedRightSizeSessionsMutation();\n const [runConflicts, conflictsState] = useEventfullymanagedResolveAgendaConflictsMutation();\n const [applyAgendaFix, applyState] = useEventfullymanagedApplyAgendaFixMutation();\n\n const noShows: NoShowDecisionView | null =\n noShowsState.data?.eventfullyManagedPredictNoShows ??\n readNoShows(savedNoShows.data?.eventfullyManagedAiDecision?.data);\n const rightSize: RightSizeDecisionView | null =\n rightSizeState.data?.eventfullyManagedRightSizeSessions ??\n readRightSizing(savedRightSize.data?.eventfullyManagedAiDecision?.data);\n const conflicts: ConflictsDecisionView | null =\n conflictsState.data?.eventfullyManagedResolveAgendaConflicts ??\n readConflicts(savedConflicts.data?.eventfullyManagedAiDecision?.data);\n\n const onRunAll = async () => {\n setActionError(null);\n try {\n await Promise.all([\n runNoShows({ variables: { eventId } }),\n runRightSize({ variables: { eventId } }),\n runConflicts({ variables: { eventId } }),\n ]);\n notify.success('AI decisions refreshed');\n } catch (error) {\n setActionError(describeError(error) ?? 'AI decision analysis failed. Live analytics remain available.');\n }\n };\n\n const onConfirmApply = async () => {\n if (!pendingApply) return;\n setActionError(null);\n try {\n const response = await applyAgendaFix({\n variables: {\n eventId,\n input: {\n sessionId: pendingApply.sessionId,\n venueId: pendingApply.venueId ?? undefined,\n startsAt: pendingApply.startsAt ?? undefined,\n endsAt: pendingApply.endsAt ?? undefined,\n capacity: pendingApply.capacity ?? undefined,\n confirm: true,\n },\n },\n });\n if (response.error || !response.data?.eventfullyManagedApplyAgendaFix) {\n setActionError(\n response.error ? (describeError(response.error) ?? 'Could not apply change.') : 'Could not apply change.'\n );\n return;\n }\n notify.success('Session updated', `Applied recommended change to ${pendingApply.sessionTitle}.`);\n setPendingApply(null);\n client.cache.evict({ fieldName: 'eventfullyManagedAiDecision' });\n client.cache.gc();\n await Promise.all([runRightSize({ variables: { eventId } }), runConflicts({ variables: { eventId } })]);\n } catch (error) {\n setActionError(describeError(error) ?? 'Could not apply session fix.');\n }\n };\n\n const running = noShowsState.loading || rightSizeState.loading || conflictsState.loading;\n\n return (\n <div className=\"mt-4 space-y-4\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <p className=\"text-xs text-text-muted\">\n Forecasts and recommendations are planning estimates; nothing changes until you explicitly confirm an action.\n </p>\n <Button type=\"button\" size=\"sm\" variant=\"secondary\" disabled={running} onClick={() => void onRunAll()}>\n <Sparkles className=\"h-4 w-4\" />\n {running ? 'Analyzing…' : 'Run all AI checks'}\n </Button>\n </div>\n\n {actionError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {actionError}\n </p>\n )}\n\n {pendingApply && (\n <ConfirmApplyBar\n pending={pendingApply}\n applying={applyState.loading}\n onConfirm={() => void onConfirmApply()}\n onCancel={() => setPendingApply(null)}\n />\n )}\n\n <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-3\">\n {/* Card 1: No-Show Prediction */}\n <div className=\"flex flex-col justify-between space-y-3 rounded-card border border-border-seam bg-bg-surface p-4\">\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <h3 className=\"flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <UserX className=\"h-4 w-4 text-accent-primary\" />\n No-show prediction\n </h3>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n disabled={noShowsState.loading}\n onClick={() => void runNoShows({ variables: { eventId } })}\n >\n {noShowsState.loading ? 'Running…' : noShows ? 'Refresh' : 'Predict'}\n </Button>\n </div>\n {noShows ? (\n <div className=\"space-y-2\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xl font-semibold tabular-nums text-text-primary\">\n {Math.round(noShows.eventNoShowRate * 100)}%\n </span>\n <Badge variant={noShows.confidence === 'LOW' ? 'warning' : 'info'}>\n {noShows.confidence.toLowerCase()} confidence\n </Badge>\n </div>\n {noShows.narrative && (\n <p className=\"rounded-md bg-bg-sunken p-2 text-xs text-text-primary\">{noShows.narrative.text}</p>\n )}\n {noShows.sessions.slice(0, 3).map((session) => (\n <div key={session.sessionId} className=\"rounded-md border border-border-seam p-2 text-xs\">\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"truncate font-medium text-text-primary\">{session.title}</span>\n <span className=\"shrink-0 tabular-nums text-text-secondary\">\n {Math.round(session.predictedNoShowRate * 100)}% no-show\n </span>\n </div>\n {session.drivers[0] && <p className=\"mt-1 text-text-muted\">{session.drivers[0]}</p>}\n </div>\n ))}\n <ProvenanceLine\n provider={\n noShowsState.data?.eventfullyManagedPredictNoShows?.engine.provider ??\n savedNoShows.data?.eventfullyManagedAiDecision?.provider\n }\n model={\n noShowsState.data?.eventfullyManagedPredictNoShows?.engine.model ??\n savedNoShows.data?.eventfullyManagedAiDecision?.model\n }\n generatedAt={\n noShowsState.data?.eventfullyManagedPredictNoShows?.engine.generatedAt ??\n savedNoShows.data?.eventfullyManagedAiDecision?.generatedAt\n }\n narrative={noShows.narrative}\n />\n </div>\n ) : (\n <p className=\"text-xs text-text-secondary\">\n No no-show prediction saved yet. Run prediction to identify sessions with higher drop-off risk.\n </p>\n )}\n </div>\n </div>\n\n {/* Card 2: Capacity Right-Sizing */}\n <div className=\"flex flex-col justify-between space-y-3 rounded-card border border-border-seam bg-bg-surface p-4\">\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <h3 className=\"flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <Scale className=\"h-4 w-4 text-accent-primary\" />\n Capacity right-sizing\n </h3>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n disabled={rightSizeState.loading}\n onClick={() => void runRightSize({ variables: { eventId } })}\n >\n {rightSizeState.loading ? 'Running…' : rightSize ? 'Refresh' : 'Check'}\n </Button>\n </div>\n {rightSize ? (\n <div className=\"space-y-2\">\n {rightSize.narrative && (\n <p className=\"rounded-md bg-bg-sunken p-2 text-xs text-text-primary\">{rightSize.narrative.text}</p>\n )}\n {rightSize.recommendations.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">No scheduled sessions to right-size for this event.</p>\n ) : (\n rightSize.recommendations.slice(0, 4).map((rec) => (\n <div key={rec.sessionId} className=\"space-y-1.5 rounded-md border border-border-seam p-2 text-xs\">\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"truncate font-medium text-text-primary\">{rec.title}</span>\n <Badge variant={rec.action === 'KEEP' ? 'secondary' : 'warning'}>{rec.action}</Badge>\n </div>\n <p className=\"text-text-secondary\">{rec.rationale}</p>\n {rec.applyable && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() =>\n setPendingApply({\n sessionId: rec.sessionId,\n sessionTitle: rec.title,\n venueId: rec.targetVenueId,\n capacity: rec.targetCapacity,\n summary: rec.targetVenueName\n ? `Move \"${rec.title}\" to ${rec.targetVenueName}${rec.targetCapacity ? ` (capacity ${rec.targetCapacity})` : ''}. ${rec.rationale}`\n : `Set \"${rec.title}\" capacity to ${rec.targetCapacity ?? rec.high}. ${rec.rationale}`,\n })\n }\n >\n Apply\n </Button>\n )}\n </div>\n ))\n )}\n <ProvenanceLine\n provider={\n rightSizeState.data?.eventfullyManagedRightSizeSessions?.engine.provider ??\n savedRightSize.data?.eventfullyManagedAiDecision?.provider\n }\n model={\n rightSizeState.data?.eventfullyManagedRightSizeSessions?.engine.model ??\n savedRightSize.data?.eventfullyManagedAiDecision?.model\n }\n generatedAt={\n rightSizeState.data?.eventfullyManagedRightSizeSessions?.engine.generatedAt ??\n savedRightSize.data?.eventfullyManagedAiDecision?.generatedAt\n }\n narrative={rightSize.narrative}\n />\n </div>\n ) : (\n <p className=\"text-xs text-text-secondary\">\n Compare predicted session turnout against room capacities to catch overflows early.\n </p>\n )}\n </div>\n </div>\n\n {/* Card 3: Agenda Conflicts */}\n <div className=\"flex flex-col justify-between space-y-3 rounded-card border border-border-seam bg-bg-surface p-4\">\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between gap-2\">\n <h3 className=\"flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <AlertTriangle className=\"h-4 w-4 text-accent-primary\" />\n Agenda conflicts\n </h3>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n disabled={conflictsState.loading}\n onClick={() => void runConflicts({ variables: { eventId } })}\n >\n {conflictsState.loading ? 'Running…' : conflicts ? 'Refresh' : 'Scan'}\n </Button>\n </div>\n {conflicts ? (\n <div className=\"space-y-2\">\n {conflicts.narrative && (\n <p className=\"rounded-md bg-bg-sunken p-2 text-xs text-text-primary\">{conflicts.narrative.text}</p>\n )}\n {conflicts.conflicts.length === 0 ? (\n <p className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n <CheckCircle2 className=\"h-4 w-4 text-accent-primary\" />\n No room clashes, double-booked speakers, or over-capacity sessions detected.\n </p>\n ) : (\n conflicts.conflicts.slice(0, 4).map((conflict, index) => (\n <div\n key={`${conflict.sessionAId}-${conflict.type}-${index}`}\n className=\"space-y-1.5 rounded-md border border-border-seam p-2 text-xs\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"truncate font-medium text-text-primary\">{conflict.sessionATitle}</span>\n <Badge variant=\"warning\">{conflict.type}</Badge>\n </div>\n <p className=\"text-text-secondary\">{conflict.message}</p>\n <p className=\"text-text-muted\">{conflict.suggestedFix.rationale}</p>\n {conflict.suggestedFix.applyable && (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() =>\n setPendingApply({\n sessionId: conflict.suggestedFix.sessionId,\n sessionTitle: conflict.sessionATitle,\n venueId: conflict.suggestedFix.targetVenueId,\n startsAt: conflict.suggestedFix.targetStartsAt,\n endsAt: conflict.suggestedFix.targetEndsAt,\n capacity: conflict.suggestedFix.targetCapacity,\n summary: conflict.suggestedFix.rationale,\n })\n }\n >\n Apply fix\n </Button>\n )}\n </div>\n ))\n )}\n <ProvenanceLine\n provider={\n conflictsState.data?.eventfullyManagedResolveAgendaConflicts?.engine.provider ??\n savedConflicts.data?.eventfullyManagedAiDecision?.provider\n }\n model={\n conflictsState.data?.eventfullyManagedResolveAgendaConflicts?.engine.model ??\n savedConflicts.data?.eventfullyManagedAiDecision?.model\n }\n generatedAt={\n conflictsState.data?.eventfullyManagedResolveAgendaConflicts?.engine.generatedAt ??\n savedConflicts.data?.eventfullyManagedAiDecision?.generatedAt\n }\n narrative={conflicts.narrative}\n />\n </div>\n ) : (\n <p className=\"text-xs text-text-secondary\">\n Scan the event schedule for room overlaps, speaker double-bookings, and capacity clashes.\n </p>\n )}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\ntype InvocationHistoryRow = {\n id: string;\n operationKey: string;\n providerKey: string;\n modelKey: string;\n trigger?: string | null;\n status: string;\n costMicroUsd?: string | null;\n};\n\nfunction AiActivityAndCreditsStrip() {\n const [windowBounds] = useState(() => {\n const to = new Date();\n const from = new Date(to.getTime() - 7 * 24 * 60 * 60 * 1000);\n return { from: from.toISOString(), to: to.toISOString() };\n });\n\n const creditsQuery = useEventfullymanagedAiCreditStatusQuery({\n variables: { productKey: 'eventfullymanaged' },\n fetchPolicy: 'network-only',\n });\n const historyQuery = useEventfullymanagedAiInvocationHistoryQuery({\n variables: {\n from: windowBounds.from,\n to: windowBounds.to,\n productKey: 'eventfullymanaged',\n first: 5,\n },\n fetchPolicy: 'network-only',\n });\n\n const credits = creditsQuery.data?.aiCreditStatus;\n const rows = useMemo<InvocationHistoryRow[]>(\n () => (historyQuery.data?.promptInvocationAttemptsV2?.nodes ?? []) as InvocationHistoryRow[],\n [historyQuery.data]\n );\n const telemetryUnavailable = Boolean(creditsQuery.error && historyQuery.error);\n\n return (\n <div className=\"mt-5 grid grid-cols-1 gap-4 border-t border-border-seam pt-4 lg:grid-cols-2\">\n {/* Credits / Cost Visibility */}\n <div className=\"space-y-2 rounded-card border border-border-seam bg-bg-surface p-4\">\n <div className=\"flex items-center justify-between gap-2\">\n <h3 className=\"flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <Coins className=\"h-4 w-4 text-accent-primary\" />\n AI credit allowance\n </h3>\n <a\n href=\"/ai\"\n className=\"inline-flex items-center gap-1 text-xs font-medium text-accent-primary hover:underline\"\n >\n Full AI Operations\n <ExternalLink className=\"h-3.5 w-3.5\" />\n </a>\n </div>\n {creditsQuery.error ? (\n <p className=\"text-xs text-text-secondary\">\n AI credit visibility is currently unavailable. Live event analytics continue normally.\n </p>\n ) : credits ? (\n <div className=\"space-y-1 text-xs text-text-secondary\">\n <p className=\"text-sm font-semibold tabular-nums text-text-primary\">\n {credits.noLimit\n ? 'Unlimited AI credits'\n : credits.provisioned\n ? `${Math.round(credits.remaining ?? 0).toLocaleString()} / ${Math.round(credits.limit ?? 0).toLocaleString()} credits remaining`\n : 'Metering not provisioned on this workspace'}\n </p>\n {credits.provisioned && !credits.noLimit && (\n <p>\n Used this cycle: {Math.round(credits.used ?? 0).toLocaleString()} credits ({credits.quotaName})\n </p>\n )}\n {credits.exhausted && (\n <p role=\"alert\" className=\"text-status-warning-text\">\n AI credits exhausted for this billing cycle. Deterministic forecasts still run without LLM narratives.\n </p>\n )}\n </div>\n ) : (\n <p className=\"text-xs text-text-muted\">Loading AI credit status…</p>\n )}\n </div>\n\n {/* Agent Activity Feed (Prompts V2 Ledger) */}\n <div className=\"space-y-2 rounded-card border border-border-seam bg-bg-surface p-4\">\n <div className=\"flex items-center justify-between gap-2\">\n <h3 className=\"flex items-center gap-1.5 text-sm font-semibold text-text-primary\">\n <Activity className=\"h-4 w-4 text-accent-primary\" />\n Recent AI activity (7 days)\n </h3>\n <span className=\"text-xs text-text-muted\">Shared ledger</span>\n </div>\n {telemetryUnavailable || historyQuery.error ? (\n <p className=\"text-xs text-text-secondary\">\n AI activity ledger is unavailable for this role or runtime. Non-AI analytics are unaffected.\n </p>\n ) : historyQuery.loading && rows.length === 0 ? (\n <p className=\"text-xs text-text-muted\">Loading recorded AI invocations…</p>\n ) : rows.length === 0 ? (\n <p className=\"text-xs text-text-secondary\">\n No hosted model calls recorded in the last 7 days for EventfullyManaged.\n </p>\n ) : (\n <ul className=\"divide-y divide-border-seam text-xs\">\n {rows.map((row) => (\n <li key={row.id} className=\"flex flex-wrap items-center justify-between gap-2 py-1.5\">\n <div className=\"min-w-0\">\n <p className=\"truncate font-medium text-text-primary\">{row.operationKey}</p>\n <p className=\"truncate text-text-muted\">\n {row.providerKey}/{row.modelKey} · {row.trigger ?? 'interactive'}\n </p>\n </div>\n <div className=\"flex shrink-0 items-center gap-2 tabular-nums\">\n <span className=\"text-text-secondary\">{formatMicroUsd(row.costMicroUsd)}</span>\n <Badge variant={row.status === 'succeeded' ? 'success' : 'warning'}>{row.status}</Badge>\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n );\n}\n\n/**\n * BOFF-3785 — AI Operations surface embedded on `/eventfullymanaged/analytics`.\n * Renders decision cards (no-show prediction, capacity right-sizing, agenda\n * conflicts with confirmed Apply), AI credit visibility, and recent V2 ledger\n * activity with graceful fallback when the AI runtime is unavailable.\n */\nexport function AiOperationsPanel({ events }: { events: readonly EventGql[] }) {\n const [selected, setSelected] = useState('');\n const eventId = events.some((event) => event.id === selected) ? selected : (events[0]?.id ?? '');\n\n return (\n <GlassCard treatment=\"insight\" className=\"p-5\">\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">AI Operations & Decision Cards</h2>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Review no-show risk, room right-sizing, agenda conflict fixes, AI credit usage, and recorded model activity.\n </p>\n </div>\n {events.length > 0 && (\n <Select value={eventId} onValueChange={setSelected}>\n <SelectTrigger aria-label=\"AI operations event\" className=\"min-h-11 w-full sm:w-64\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {events.map((event) => (\n <SelectItem key={event.id} value={event.id}>\n {event.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n </div>\n\n {eventId ? (\n <EventDecisionSuite key={eventId} eventId={eventId} />\n ) : (\n <p className=\"mt-4 text-sm text-text-secondary\">Create an event to run AI decision checks.</p>\n )}\n\n <AiActivityAndCreditsStrip />\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;AAiHA,SAASC,EAAS,GAAgD;CAChE,OAAOC,KAAS,OAAOA,KAAU,YAAY,CAAC,MAAM,QAAQA,CAAK,IAAKA,IAAoC;AAC5G;AAEA,SAASC,EAAc,GAAsC;CAC3D,IAAMC,IAAMH,EAASC,CAAK;CAI1B,OAHI,CAACE,KACD,OAAOA,EAAIC,QAAY,YAAY,CAACD,EAAIC,KAAQ,KAAK,KACrD,OAAOD,EAAIE,YAAgB,YAAY,OAAOF,EAAIG,SAAa,WAAiB,OAC7E;EAAE,MAAMH,EAAIC;EAAS,UAAUD,EAAIE;EAAa,OAAOF,EAAIG;CAAS;AAC7E;AAEA,SAASC,EAAY,GAAyC;CAC5D,IAAMC,IAAOR,EAASS,CAAG,GACnBN,IAAMH,EAASQ,GAAOE,MAAS,KAAKF;CAC1C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AAU,WAAU;EAAzC,UAAA;GACE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;KAAI,WAAU;KAA4C,UAAA;IAAsC,CAAA,GAChG,kBAAC,KAAD;KAAG,WAAU;KAAmC,UAAA;IAE7C,CAAA,CACA,EAAA,CAAA,GACJF,EAAO,SAAS,KACf,kBAACG,GAAD;KAAQ,OAAOJ;KAAS,eAAeD;KAAvC,UAAA,CACE,kBAACM,GAAD;MAAe,cAAW;MAAsB,WAAU;MACxD,UAAA,kBAACC,GAAD,CAAc,CAAA;KACD,CAAA,GACf,kBAACC,GAAD,EAAA,UACGN,EAAO,KAAK,MACX,kBAACO,GAAD;MAA2B,OAAON,EAAM;MACrC,UAAAA,EAAM;KACG,GAFKA,EAAM,EAEX,CACb,EACY,CAAA,CACT;IAEP,CAAA,CAAA;;GAEJF,IACC,kBAAC/D,GAAD,EAA2C,WAAU,GAA5B+D,CAA4B,IAErD,kBAAC,KAAD;IAAG,WAAU;IAAmC,UAAA;GAA6C,CAAA;GAG/F,kBAAClB,GAAD,CAA4B,CAAA;EACnB;;AAEf"}
|
|
@@ -5,20 +5,30 @@ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
|
5
5
|
import { Badge as s, Button as c, GlassCard as l, Select as u, SelectContent as d, SelectItem as f, SelectTrigger as p, SelectValue as m } from "@burdenoff/fe-libs/ui";
|
|
6
6
|
// src/eventfullymanaged/components/AttendanceForecast.tsx
|
|
7
7
|
function h(e) {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
return typeof e != "object" || !e || !("text" in e) || typeof e.text != "string" || !e.text.trim() || !("provider" in e) || typeof e.provider != "string" || !("model" in e) || typeof e.model != "string" ? null : {
|
|
9
|
+
text: e.text,
|
|
10
|
+
provider: e.provider,
|
|
11
|
+
model: e.model
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function g(e) {
|
|
15
|
+
if (typeof e != "object" || !e) return null;
|
|
16
|
+
let t = "result" in e && typeof e.result == "object" && e.result !== null ? e.result : e;
|
|
17
|
+
if (!("eventId" in t) || typeof t.eventId != "string" || !("predictedAttendance" in t) || typeof t.predictedAttendance != "number" || !("registered" in t) || typeof t.registered != "number" || !("low" in t) || typeof t.low != "number" || !("high" in t) || typeof t.high != "number" || !("confidence" in t) || typeof t.confidence != "string" || !("coldStart" in t) || typeof t.coldStart != "boolean") return null;
|
|
18
|
+
let n = "coldStartReason" in t && typeof t.coldStartReason == "string" ? t.coldStartReason : null, r = h("narrative" in t ? t.narrative : null) ?? h("narrative" in e ? e.narrative : null);
|
|
10
19
|
return {
|
|
11
|
-
eventId:
|
|
12
|
-
predictedAttendance:
|
|
13
|
-
registered:
|
|
14
|
-
low:
|
|
15
|
-
high:
|
|
16
|
-
confidence:
|
|
17
|
-
coldStart:
|
|
18
|
-
coldStartReason:
|
|
20
|
+
eventId: t.eventId,
|
|
21
|
+
predictedAttendance: t.predictedAttendance,
|
|
22
|
+
registered: t.registered,
|
|
23
|
+
low: t.low,
|
|
24
|
+
high: t.high,
|
|
25
|
+
confidence: t.confidence,
|
|
26
|
+
coldStart: t.coldStart,
|
|
27
|
+
coldStartReason: n,
|
|
28
|
+
narrative: r
|
|
19
29
|
};
|
|
20
30
|
}
|
|
21
|
-
function
|
|
31
|
+
function _(t) {
|
|
22
32
|
let [i, a] = e(), [o, s] = r(null);
|
|
23
33
|
return {
|
|
24
34
|
result: a.data?.eventfullyManagedForecastAttendance,
|
|
@@ -35,26 +45,33 @@ function g(t) {
|
|
|
35
45
|
}
|
|
36
46
|
};
|
|
37
47
|
}
|
|
38
|
-
function
|
|
48
|
+
function v(e) {
|
|
39
49
|
if (!e) return null;
|
|
40
50
|
let t = new Date(e);
|
|
41
51
|
return Number.isNaN(t.getTime()) ? null : t.toLocaleString();
|
|
42
52
|
}
|
|
43
|
-
function
|
|
44
|
-
let
|
|
53
|
+
function y({ forecast: e, generatedAt: t, provider: n, model: r }) {
|
|
54
|
+
let c = v(t), l = e.narrative?.model ?? r, u = e.narrative?.provider ?? n;
|
|
45
55
|
return /* @__PURE__ */ o("div", {
|
|
46
56
|
className: "space-y-3",
|
|
47
57
|
"aria-live": "polite",
|
|
48
58
|
children: [
|
|
49
59
|
/* @__PURE__ */ o("div", {
|
|
50
60
|
className: "flex flex-wrap items-center gap-3",
|
|
51
|
-
children: [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ o("p", {
|
|
63
|
+
className: "text-2xl font-semibold tabular-nums text-text-primary",
|
|
64
|
+
children: [e.predictedAttendance.toLocaleString(), " expected attendees"]
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ o(s, {
|
|
67
|
+
variant: e.confidence === "LOW" ? "warning" : "info",
|
|
68
|
+
children: [e.confidence.toLowerCase(), " confidence"]
|
|
69
|
+
}),
|
|
70
|
+
l && /* @__PURE__ */ a(s, {
|
|
71
|
+
variant: "secondary",
|
|
72
|
+
children: u && !l.includes("/") ? `${u}/${l}` : l
|
|
73
|
+
})
|
|
74
|
+
]
|
|
58
75
|
}),
|
|
59
76
|
/* @__PURE__ */ o("p", {
|
|
60
77
|
className: "text-sm text-text-secondary",
|
|
@@ -69,22 +86,26 @@ function v({ forecast: e, generatedAt: t }) {
|
|
|
69
86
|
" registered"
|
|
70
87
|
]
|
|
71
88
|
}),
|
|
89
|
+
e.narrative && /* @__PURE__ */ a("p", {
|
|
90
|
+
className: "rounded-md border border-border-seam bg-bg-sunken p-3 text-sm text-text-primary",
|
|
91
|
+
children: e.narrative.text
|
|
92
|
+
}),
|
|
72
93
|
e.coldStart && /* @__PURE__ */ a("p", {
|
|
73
94
|
className: "text-sm text-status-warning-text",
|
|
74
95
|
children: e.coldStartReason ?? "Limited historical check-ins. This forecast uses a baseline assumption."
|
|
75
96
|
}),
|
|
76
97
|
/* @__PURE__ */ o("p", {
|
|
77
98
|
className: "text-xs text-text-muted",
|
|
78
|
-
children: ["Estimate for planning; actual turnout may differ. Generating a forecast does not change your event or sessions.",
|
|
99
|
+
children: ["Estimate for planning; actual turnout may differ. Generating a forecast does not change your event or sessions.", c && /* @__PURE__ */ o(i, { children: [
|
|
79
100
|
" Last generated ",
|
|
80
|
-
|
|
101
|
+
c,
|
|
81
102
|
"."
|
|
82
103
|
] })]
|
|
83
104
|
})
|
|
84
105
|
]
|
|
85
106
|
});
|
|
86
107
|
}
|
|
87
|
-
function
|
|
108
|
+
function b({ loading: e, failed: t, hasSnapshot: n }) {
|
|
88
109
|
return t ? null : e ? /* @__PURE__ */ a("p", {
|
|
89
110
|
role: "status",
|
|
90
111
|
className: "text-sm text-text-secondary",
|
|
@@ -94,14 +115,14 @@ function y({ loading: e, failed: t, hasSnapshot: n }) {
|
|
|
94
115
|
children: n ? "The saved forecast uses an unsupported format. Generate a fresh forecast to view it here." : "No forecast yet. Generate one using this event's registrations and past check-ins."
|
|
95
116
|
});
|
|
96
117
|
}
|
|
97
|
-
function
|
|
118
|
+
function x(e, t) {
|
|
98
119
|
return e ? "Forecasting…" : t ? "Refresh forecast" : "Generate forecast";
|
|
99
120
|
}
|
|
100
|
-
function
|
|
121
|
+
function S({ eventId: e }) {
|
|
101
122
|
let n = t({
|
|
102
123
|
variables: { eventId: e },
|
|
103
124
|
fetchPolicy: "network-only"
|
|
104
|
-
}), r =
|
|
125
|
+
}), r = _(e), i = n.data?.eventfullyManagedAiDecision, s = r.result, l = s ?? g(i?.data), u = l?.eventId === e ? l : null, d = s?.engine?.generatedAt ?? i?.generatedAt, f = s?.engine?.provider ?? i?.provider ?? null, p = s?.engine?.model ?? i?.model ?? null, m = r.error ?? (!s && n.error ? "The saved forecast could not be loaded. You can retry by generating a new forecast." : null);
|
|
105
126
|
return /* @__PURE__ */ o("div", {
|
|
106
127
|
className: "mt-4 space-y-3",
|
|
107
128
|
children: [
|
|
@@ -111,17 +132,19 @@ function x({ eventId: e }) {
|
|
|
111
132
|
variant: "secondary",
|
|
112
133
|
onClick: () => void r.generate(),
|
|
113
134
|
disabled: r.loading,
|
|
114
|
-
children:
|
|
135
|
+
children: x(r.loading, !!u)
|
|
115
136
|
}),
|
|
116
|
-
|
|
137
|
+
m && /* @__PURE__ */ a("p", {
|
|
117
138
|
role: "alert",
|
|
118
139
|
className: "text-sm text-status-error-text",
|
|
119
|
-
children:
|
|
140
|
+
children: m
|
|
120
141
|
}),
|
|
121
|
-
u ? /* @__PURE__ */ a(
|
|
142
|
+
u ? /* @__PURE__ */ a(y, {
|
|
122
143
|
forecast: u,
|
|
123
|
-
generatedAt: d
|
|
124
|
-
|
|
144
|
+
generatedAt: d,
|
|
145
|
+
provider: f,
|
|
146
|
+
model: p
|
|
147
|
+
}) : /* @__PURE__ */ a(b, {
|
|
125
148
|
loading: n.loading,
|
|
126
149
|
failed: !!n.error,
|
|
127
150
|
hasSnapshot: !!i
|
|
@@ -129,13 +152,13 @@ function x({ eventId: e }) {
|
|
|
129
152
|
]
|
|
130
153
|
});
|
|
131
154
|
}
|
|
132
|
-
function
|
|
133
|
-
let [g, _] = r(""), [v, y] = r(!1), [b,
|
|
134
|
-
y(!0),
|
|
155
|
+
function C({ events: e, total: t, loading: n, failed: i, loadMore: s, reload: h }) {
|
|
156
|
+
let [g, _] = r(""), [v, y] = r(!1), [b, x] = r(!1), C = e.some((e) => e.id === g) ? g : e[0]?.id ?? "", w = async () => {
|
|
157
|
+
y(!0), x(!1);
|
|
135
158
|
try {
|
|
136
159
|
await (i ? h() : s());
|
|
137
160
|
} catch {
|
|
138
|
-
|
|
161
|
+
x(!0);
|
|
139
162
|
} finally {
|
|
140
163
|
y(!1);
|
|
141
164
|
}
|
|
@@ -199,7 +222,7 @@ function S({ events: e, total: t, loading: n, failed: i, loadMore: s, reload: h
|
|
|
199
222
|
children: v ? "Loading events…" : "Load more events"
|
|
200
223
|
})]
|
|
201
224
|
}),
|
|
202
|
-
C ? /* @__PURE__ */ a(
|
|
225
|
+
C ? /* @__PURE__ */ a(S, { eventId: C }, C) : n ? /* @__PURE__ */ a("p", {
|
|
203
226
|
role: "status",
|
|
204
227
|
className: "mt-4 text-sm text-text-secondary",
|
|
205
228
|
children: "Loading events…"
|
|
@@ -210,6 +233,6 @@ function S({ events: e, total: t, loading: n, failed: i, loadMore: s, reload: h
|
|
|
210
233
|
]
|
|
211
234
|
});
|
|
212
235
|
}
|
|
213
|
-
export {
|
|
236
|
+
export { C as AttendanceForecast };
|
|
214
237
|
|
|
215
238
|
//# sourceMappingURL=AttendanceForecast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttendanceForecast.js","names":["_Fragment","readForecast","value","reason","useForecastGeneration","generate","generated","useEventfullymanagedForecastAttendanceMutation","generationError","setGenerationError","useState","result","describeError","error","formatForecastTime","parsed","ForecastSummary","formattedTime","generatedAt","forecast","Badge","Fragment","ForecastNotice","failed","loading","hasSnapshot","forecastActionLabel","hasForecast","EventForecast","saved","useEventfullymanagedSavedAttendanceForecastQuery","generation","eventId","snapshot","latest","current","Button","AttendanceForecast","selected","setSelected","loadingMore","setLoadingMore","loadMoreFailed","setLoadMoreFailed","events","event","onLoadMore","reload","loadMore","GlassCard","Select","SelectTrigger","SelectValue","SelectContent","SelectItem","total"],"sources":["../../../src/eventfullymanaged/components/AttendanceForecast.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n Badge,\n Button,\n GlassCard,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n useEventfullymanagedForecastAttendanceMutation,\n useEventfullymanagedSavedAttendanceForecastQuery,\n} from '../../generated/wspace-operations';\nimport type { EventGql } from '../api/eventApi';\nimport { describeError } from '../lib/mutationResult';\n\ntype Forecast = {\n eventId: string;\n predictedAttendance: number;\n registered: number;\n low: number;\n high: number;\n confidence: string;\n coldStart: boolean;\n coldStartReason?: string | null;\n};\n\n/** Snapshot JSON is versioned server data; reject incompatible payloads instead of inventing values. */\nfunction readForecast(value: unknown): Forecast | null {\n if (typeof value !== 'object' || value === null) return null;\n if (!('eventId' in value) || typeof value.eventId !== 'string') return null;\n if (!('predictedAttendance' in value) || typeof value.predictedAttendance !== 'number') return null;\n if (!('registered' in value) || typeof value.registered !== 'number') return null;\n if (!('low' in value) || typeof value.low !== 'number') return null;\n if (!('high' in value) || typeof value.high !== 'number') return null;\n if (!('confidence' in value) || typeof value.confidence !== 'string') return null;\n if (!('coldStart' in value) || typeof value.coldStart !== 'boolean') return null;\n const reason = 'coldStartReason' in value && typeof value.coldStartReason === 'string' ? value.coldStartReason : null;\n return {\n eventId: value.eventId,\n predictedAttendance: value.predictedAttendance,\n registered: value.registered,\n low: value.low,\n high: value.high,\n confidence: value.confidence,\n coldStart: value.coldStart,\n coldStartReason: reason,\n };\n}\n\nfunction useForecastGeneration(eventId: string) {\n const [generate, generated] = useEventfullymanagedForecastAttendanceMutation();\n const [generationError, setGenerationError] = useState<string | null>(null);\n const onGenerate = async () => {\n setGenerationError(null);\n try {\n const result = await generate({ variables: { eventId } });\n if (result.error || !result.data?.eventfullyManagedForecastAttendance) {\n setGenerationError(\n result.error\n ? (describeError(result.error) ?? 'The forecast could not be generated.')\n : 'No forecast was returned. Please try again.'\n );\n }\n } catch (error) {\n setGenerationError(describeError(error) ?? 'The forecast could not be generated. Please try again.');\n }\n };\n\n return {\n result: generated.data?.eventfullyManagedForecastAttendance,\n loading: generated.loading,\n error: generationError,\n generate: onGenerate,\n };\n}\n\nfunction formatForecastTime(value?: string | null): string | null {\n if (!value) return null;\n const parsed = new Date(value);\n return Number.isNaN(parsed.getTime()) ? null : parsed.toLocaleString();\n}\n\nfunction ForecastSummary({ forecast, generatedAt }: { forecast: Forecast; generatedAt?: string | null }) {\n const formattedTime = formatForecastTime(generatedAt);\n return (\n <div className=\"space-y-3\" aria-live=\"polite\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <p className=\"text-2xl font-semibold tabular-nums text-text-primary\">\n {forecast.predictedAttendance.toLocaleString()} expected attendees\n </p>\n <Badge variant={forecast.confidence === 'LOW' ? 'warning' : 'info'}>\n {forecast.confidence.toLowerCase()} confidence\n </Badge>\n </div>\n <p className=\"text-sm text-text-secondary\">\n 90% planning range: {forecast.low.toLocaleString()}–{forecast.high.toLocaleString()} ·{' '}\n {forecast.registered.toLocaleString()} registered\n </p>\n {forecast.coldStart && (\n <p className=\"text-sm text-status-warning-text\">\n {forecast.coldStartReason ?? 'Limited historical check-ins. This forecast uses a baseline assumption.'}\n </p>\n )}\n <p className=\"text-xs text-text-muted\">\n Estimate for planning; actual turnout may differ. Generating a forecast does not change your event or sessions.\n {formattedTime && <> Last generated {formattedTime}.</>}\n </p>\n </div>\n );\n}\n\nfunction ForecastNotice({ loading, failed, hasSnapshot }: { loading: boolean; failed: boolean; hasSnapshot: boolean }) {\n if (failed) return null;\n if (loading)\n return (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n Loading saved forecast…\n </p>\n );\n return (\n <p className=\"text-sm text-text-secondary\">\n {hasSnapshot\n ? 'The saved forecast uses an unsupported format. Generate a fresh forecast to view it here.'\n : \"No forecast yet. Generate one using this event's registrations and past check-ins.\"}\n </p>\n );\n}\n\nfunction forecastActionLabel(loading: boolean, hasForecast: boolean): string {\n if (loading) return 'Forecasting…';\n return hasForecast ? 'Refresh forecast' : 'Generate forecast';\n}\n\n/** Event keys also scope mutation state when a request finishes after an event switch. */\nfunction EventForecast({ eventId }: { eventId: string }) {\n const saved = useEventfullymanagedSavedAttendanceForecastQuery({\n variables: { eventId },\n fetchPolicy: 'network-only',\n });\n const generation = useForecastGeneration(eventId);\n const snapshot = saved.data?.eventfullyManagedAiDecision;\n const latest = generation.result;\n const forecast = latest ?? readForecast(snapshot?.data);\n const current = forecast?.eventId === eventId ? forecast : null;\n const generatedAt = latest?.engine?.generatedAt ?? snapshot?.generatedAt;\n const error =\n generation.error ??\n (!latest && saved.error\n ? 'The saved forecast could not be loaded. You can retry by generating a new forecast.'\n : null);\n\n return (\n <div className=\"mt-4 space-y-3\">\n <Button\n className=\"min-h-11\"\n type=\"button\"\n variant=\"secondary\"\n onClick={() => void generation.generate()}\n disabled={generation.loading}\n >\n {forecastActionLabel(generation.loading, Boolean(current))}\n </Button>\n {error && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n {current ? (\n <ForecastSummary forecast={current} generatedAt={generatedAt} />\n ) : (\n <ForecastNotice loading={saved.loading} failed={Boolean(saved.error)} hasSnapshot={Boolean(snapshot)} />\n )}\n </div>\n );\n}\n\nexport function AttendanceForecast({\n events,\n total,\n loading,\n failed,\n loadMore,\n reload,\n}: {\n events: EventGql[];\n total: number;\n loading: boolean;\n failed: boolean;\n loadMore: () => Promise<unknown>;\n reload: () => Promise<unknown>;\n}) {\n const [selected, setSelected] = useState('');\n const [loadingMore, setLoadingMore] = useState(false);\n const [loadMoreFailed, setLoadMoreFailed] = useState(false);\n const eventId = events.some((event) => event.id === selected) ? selected : (events[0]?.id ?? '');\n\n const onLoadMore = async () => {\n setLoadingMore(true);\n setLoadMoreFailed(false);\n try {\n await (failed ? reload() : loadMore());\n } catch {\n setLoadMoreFailed(true);\n } finally {\n setLoadingMore(false);\n }\n };\n\n return (\n <GlassCard treatment=\"insight\" className=\"p-5\">\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">Attendance forecast</h2>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Plan staffing and catering with an estimate from real registration and check-in history.\n </p>\n </div>\n {events.length > 0 && (\n <Select value={eventId} onValueChange={setSelected}>\n <SelectTrigger aria-label=\"Forecast event\" className=\"min-h-11 w-full sm:w-64\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {events.map((event) => (\n <SelectItem key={event.id} value={event.id}>\n {event.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n </div>\n {(failed || loadMoreFailed) && (\n <div className=\"mt-3 flex flex-wrap items-center gap-3\">\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n Events could not be loaded. Please try again.\n </p>\n <Button\n className=\"min-h-11\"\n type=\"button\"\n variant=\"ghost\"\n disabled={loading || loadingMore}\n onClick={() => void onLoadMore()}\n >\n Retry events\n </Button>\n </div>\n )}\n {events.length < total && (\n <div className=\"mt-3 flex flex-wrap items-center gap-3\">\n <p className=\"text-xs text-text-muted\">\n {events.length.toLocaleString()} of {total.toLocaleString()} events loaded.\n </p>\n <Button\n className=\"min-h-11\"\n type=\"button\"\n variant=\"ghost\"\n disabled={loading || loadingMore}\n onClick={() => void onLoadMore()}\n >\n {loadingMore ? 'Loading events…' : 'Load more events'}\n </Button>\n </div>\n )}\n {eventId ? (\n <EventForecast key={eventId} eventId={eventId} />\n ) : loading ? (\n <p role=\"status\" className=\"mt-4 text-sm text-text-secondary\">\n Loading events…\n </p>\n ) : failed ? null : (\n <p className=\"mt-4 text-sm text-text-secondary\">Create an event to start forecasting attendance.</p>\n )}\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;AA+BA,SAASC,EAAa,GAAiC;CAQrD,IAPI,OAAOC,KAAU,aAAYA,KAC7B,EAAE,aAAaA,MAAU,OAAOA,EAAM,WAAY,YAClD,EAAE,yBAAyBA,MAAU,OAAOA,EAAM,uBAAwB,YAC1E,EAAE,gBAAgBA,MAAU,OAAOA,EAAM,cAAe,YACxD,EAAE,SAASA,MAAU,OAAOA,EAAM,OAAQ,YAC1C,EAAE,UAAUA,MAAU,OAAOA,EAAM,QAAS,YAC5C,EAAE,gBAAgBA,MAAU,OAAOA,EAAM,cAAe,YACxD,EAAE,eAAeA,MAAU,OAAOA,EAAM,aAAc,WAAW,OAAO;CAC5E,IAAMC,IAAS,qBAAqBD,KAAS,OAAOA,EAAM,mBAAoB,WAAWA,EAAM,kBAAkB;CACjH,OAAO;EACL,SAASA,EAAM;EACf,qBAAqBA,EAAM;EAC3B,YAAYA,EAAM;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AFKA,EAAM,EAEX,CACb,EACY,CAAA,CACT;IAEP,CAAA,CAAA;;IACHtB,KAAUmB,MACV,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,MAAK;KAAQ,WAAU;KAAiC,UAAA;IAExD,CAAA,GACH,kBAACN,GAAD;KACE,WAAU;KACV,MAAK;KACL,SAAQ;KACR,UAAUZ,KAAWgB;KACrB,eAAe,KAAKM,EAAW;KAChC,UAAA;IAEO,CAAA,CACL;;GAENF,EAAO,SAASW,KACf,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACGX,EAAO,OAAO,eAAe;MAAE;MAAKW,EAAM,eAAe;MAAE;KAC3D;IACH,CAAA,GAAA,kBAACnB,GAAD;KACE,WAAU;KACV,MAAK;KACL,SAAQ;KACR,UAAUZ,KAAWgB;KACrB,eAAe,KAAKM,EAAW;KAE9B,UAAAN,IAAc,oBAAoB;IAC7B,CAAA,CACL;;GAENR,IACC,kBAACJ,GAAD,EAAsC,WAAU,GAA5BI,CAA4B,IAC9CR,IACF,kBAAC,KAAD;IAAG,MAAK;IAAS,WAAU;IAAmC,UAAA;GAE3D,CAAA,IACDD,IAAS,OACX,kBAAC,KAAD;IAAG,WAAU;IAAmC,UAAA;GAAmD,CAAA;EAE5F;;AAEf"}
|
|
1
|
+
{"version":3,"file":"AttendanceForecast.js","names":["_Fragment","readNarrative","value","readForecast","candidate","reason","narrative","useForecastGeneration","generate","generated","useEventfullymanagedForecastAttendanceMutation","generationError","setGenerationError","useState","result","describeError","error","formatForecastTime","parsed","ForecastSummary","formattedTime","generatedAt","provenanceModel","forecast","model","provenanceProvider","provider","Badge","Fragment","ForecastNotice","failed","loading","hasSnapshot","forecastActionLabel","hasForecast","EventForecast","saved","useEventfullymanagedSavedAttendanceForecastQuery","generation","eventId","snapshot","latest","current","Button","AttendanceForecast","selected","setSelected","loadingMore","setLoadingMore","loadMoreFailed","setLoadMoreFailed","events","event","onLoadMore","reload","loadMore","GlassCard","Select","SelectTrigger","SelectValue","SelectContent","SelectItem","total"],"sources":["../../../src/eventfullymanaged/components/AttendanceForecast.tsx"],"sourcesContent":["import { useState } from 'react';\nimport {\n Badge,\n Button,\n GlassCard,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n useEventfullymanagedForecastAttendanceMutation,\n useEventfullymanagedSavedAttendanceForecastQuery,\n} from '../../generated/wspace-operations';\nimport type { EventGql } from '../api/eventApi';\nimport { describeError } from '../lib/mutationResult';\n\ntype DecisionNarrative = {\n text: string;\n provider: string;\n model: string;\n};\n\ntype Forecast = {\n eventId: string;\n predictedAttendance: number;\n registered: number;\n low: number;\n high: number;\n confidence: string;\n coldStart: boolean;\n coldStartReason?: string | null;\n narrative?: DecisionNarrative | null;\n};\n\nfunction readNarrative(value: unknown): DecisionNarrative | null {\n if (typeof value !== 'object' || value === null) return null;\n if (!('text' in value) || typeof value.text !== 'string' || !value.text.trim()) return null;\n if (!('provider' in value) || typeof value.provider !== 'string') return null;\n if (!('model' in value) || typeof value.model !== 'string') return null;\n return { text: value.text, provider: value.provider, model: value.model };\n}\n\n/** Snapshot JSON is versioned server data; reject incompatible payloads instead of inventing values. */\nfunction readForecast(value: unknown): Forecast | null {\n if (typeof value !== 'object' || value === null) return null;\n const candidate =\n 'result' in value && typeof value.result === 'object' && value.result !== null ? value.result : value;\n if (!('eventId' in candidate) || typeof candidate.eventId !== 'string') return null;\n if (!('predictedAttendance' in candidate) || typeof candidate.predictedAttendance !== 'number') return null;\n if (!('registered' in candidate) || typeof candidate.registered !== 'number') return null;\n if (!('low' in candidate) || typeof candidate.low !== 'number') return null;\n if (!('high' in candidate) || typeof candidate.high !== 'number') return null;\n if (!('confidence' in candidate) || typeof candidate.confidence !== 'string') return null;\n if (!('coldStart' in candidate) || typeof candidate.coldStart !== 'boolean') return null;\n const reason =\n 'coldStartReason' in candidate && typeof candidate.coldStartReason === 'string' ? candidate.coldStartReason : null;\n const narrative =\n readNarrative('narrative' in candidate ? candidate.narrative : null) ??\n readNarrative('narrative' in value ? value.narrative : null);\n return {\n eventId: candidate.eventId,\n predictedAttendance: candidate.predictedAttendance,\n registered: candidate.registered,\n low: candidate.low,\n high: candidate.high,\n confidence: candidate.confidence,\n coldStart: candidate.coldStart,\n coldStartReason: reason,\n narrative,\n };\n}\n\nfunction useForecastGeneration(eventId: string) {\n const [generate, generated] = useEventfullymanagedForecastAttendanceMutation();\n const [generationError, setGenerationError] = useState<string | null>(null);\n const onGenerate = async () => {\n setGenerationError(null);\n try {\n const result = await generate({ variables: { eventId } });\n if (result.error || !result.data?.eventfullyManagedForecastAttendance) {\n setGenerationError(\n result.error\n ? (describeError(result.error) ?? 'The forecast could not be generated.')\n : 'No forecast was returned. Please try again.'\n );\n }\n } catch (error) {\n setGenerationError(describeError(error) ?? 'The forecast could not be generated. Please try again.');\n }\n };\n\n return {\n result: generated.data?.eventfullyManagedForecastAttendance,\n loading: generated.loading,\n error: generationError,\n generate: onGenerate,\n };\n}\n\nfunction formatForecastTime(value?: string | null): string | null {\n if (!value) return null;\n const parsed = new Date(value);\n return Number.isNaN(parsed.getTime()) ? null : parsed.toLocaleString();\n}\n\nfunction ForecastSummary({\n forecast,\n generatedAt,\n provider,\n model,\n}: {\n forecast: Forecast;\n generatedAt?: string | null;\n provider?: string | null;\n model?: string | null;\n}) {\n const formattedTime = formatForecastTime(generatedAt);\n const provenanceModel = forecast.narrative?.model ?? model;\n const provenanceProvider = forecast.narrative?.provider ?? provider;\n return (\n <div className=\"space-y-3\" aria-live=\"polite\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <p className=\"text-2xl font-semibold tabular-nums text-text-primary\">\n {forecast.predictedAttendance.toLocaleString()} expected attendees\n </p>\n <Badge variant={forecast.confidence === 'LOW' ? 'warning' : 'info'}>\n {forecast.confidence.toLowerCase()} confidence\n </Badge>\n {provenanceModel && (\n <Badge variant=\"secondary\">\n {provenanceProvider && !provenanceModel.includes('/')\n ? `${provenanceProvider}/${provenanceModel}`\n : provenanceModel}\n </Badge>\n )}\n </div>\n <p className=\"text-sm text-text-secondary\">\n 90% planning range: {forecast.low.toLocaleString()}–{forecast.high.toLocaleString()} ·{' '}\n {forecast.registered.toLocaleString()} registered\n </p>\n {forecast.narrative && (\n <p className=\"rounded-md border border-border-seam bg-bg-sunken p-3 text-sm text-text-primary\">\n {forecast.narrative.text}\n </p>\n )}\n {forecast.coldStart && (\n <p className=\"text-sm text-status-warning-text\">\n {forecast.coldStartReason ?? 'Limited historical check-ins. This forecast uses a baseline assumption.'}\n </p>\n )}\n <p className=\"text-xs text-text-muted\">\n Estimate for planning; actual turnout may differ. Generating a forecast does not change your event or sessions.\n {formattedTime && <> Last generated {formattedTime}.</>}\n </p>\n </div>\n );\n}\n\nfunction ForecastNotice({ loading, failed, hasSnapshot }: { loading: boolean; failed: boolean; hasSnapshot: boolean }) {\n if (failed) return null;\n if (loading)\n return (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n Loading saved forecast…\n </p>\n );\n return (\n <p className=\"text-sm text-text-secondary\">\n {hasSnapshot\n ? 'The saved forecast uses an unsupported format. Generate a fresh forecast to view it here.'\n : \"No forecast yet. Generate one using this event's registrations and past check-ins.\"}\n </p>\n );\n}\n\nfunction forecastActionLabel(loading: boolean, hasForecast: boolean): string {\n if (loading) return 'Forecasting…';\n return hasForecast ? 'Refresh forecast' : 'Generate forecast';\n}\n\n/** Event keys also scope mutation state when a request finishes after an event switch. */\nfunction EventForecast({ eventId }: { eventId: string }) {\n const saved = useEventfullymanagedSavedAttendanceForecastQuery({\n variables: { eventId },\n fetchPolicy: 'network-only',\n });\n const generation = useForecastGeneration(eventId);\n const snapshot = saved.data?.eventfullyManagedAiDecision;\n const latest = generation.result;\n const forecast = latest ?? readForecast(snapshot?.data);\n const current = forecast?.eventId === eventId ? forecast : null;\n const generatedAt = latest?.engine?.generatedAt ?? snapshot?.generatedAt;\n const provider = latest?.engine?.provider ?? snapshot?.provider ?? null;\n const model = latest?.engine?.model ?? snapshot?.model ?? null;\n const error =\n generation.error ??\n (!latest && saved.error\n ? 'The saved forecast could not be loaded. You can retry by generating a new forecast.'\n : null);\n\n return (\n <div className=\"mt-4 space-y-3\">\n <Button\n className=\"min-h-11\"\n type=\"button\"\n variant=\"secondary\"\n onClick={() => void generation.generate()}\n disabled={generation.loading}\n >\n {forecastActionLabel(generation.loading, Boolean(current))}\n </Button>\n {error && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {error}\n </p>\n )}\n {current ? (\n <ForecastSummary forecast={current} generatedAt={generatedAt} provider={provider} model={model} />\n ) : (\n <ForecastNotice loading={saved.loading} failed={Boolean(saved.error)} hasSnapshot={Boolean(snapshot)} />\n )}\n </div>\n );\n}\n\nexport function AttendanceForecast({\n events,\n total,\n loading,\n failed,\n loadMore,\n reload,\n}: {\n events: EventGql[];\n total: number;\n loading: boolean;\n failed: boolean;\n loadMore: () => Promise<unknown>;\n reload: () => Promise<unknown>;\n}) {\n const [selected, setSelected] = useState('');\n const [loadingMore, setLoadingMore] = useState(false);\n const [loadMoreFailed, setLoadMoreFailed] = useState(false);\n const eventId = events.some((event) => event.id === selected) ? selected : (events[0]?.id ?? '');\n\n const onLoadMore = async () => {\n setLoadingMore(true);\n setLoadMoreFailed(false);\n try {\n await (failed ? reload() : loadMore());\n } catch {\n setLoadMoreFailed(true);\n } finally {\n setLoadingMore(false);\n }\n };\n\n return (\n <GlassCard treatment=\"insight\" className=\"p-5\">\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">Attendance forecast</h2>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Plan staffing and catering with an estimate from real registration and check-in history.\n </p>\n </div>\n {events.length > 0 && (\n <Select value={eventId} onValueChange={setSelected}>\n <SelectTrigger aria-label=\"Forecast event\" className=\"min-h-11 w-full sm:w-64\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {events.map((event) => (\n <SelectItem key={event.id} value={event.id}>\n {event.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n </div>\n {(failed || loadMoreFailed) && (\n <div className=\"mt-3 flex flex-wrap items-center gap-3\">\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n Events could not be loaded. Please try again.\n </p>\n <Button\n className=\"min-h-11\"\n type=\"button\"\n variant=\"ghost\"\n disabled={loading || loadingMore}\n onClick={() => void onLoadMore()}\n >\n Retry events\n </Button>\n </div>\n )}\n {events.length < total && (\n <div className=\"mt-3 flex flex-wrap items-center gap-3\">\n <p className=\"text-xs text-text-muted\">\n {events.length.toLocaleString()} of {total.toLocaleString()} events loaded.\n </p>\n <Button\n className=\"min-h-11\"\n type=\"button\"\n variant=\"ghost\"\n disabled={loading || loadingMore}\n onClick={() => void onLoadMore()}\n >\n {loadingMore ? 'Loading events…' : 'Load more events'}\n </Button>\n </div>\n )}\n {eventId ? (\n <EventForecast key={eventId} eventId={eventId} />\n ) : loading ? (\n <p role=\"status\" className=\"mt-4 text-sm text-text-secondary\">\n Loading events…\n </p>\n ) : failed ? null : (\n <p className=\"mt-4 text-sm text-text-secondary\">Create an event to start forecasting attendance.</p>\n )}\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;AAqCA,SAASC,EAAc,GAA0C;CAK/D,OAJI,OAAOC,KAAU,aAAYA,KAC7B,EAAE,UAAUA,MAAU,OAAOA,EAAM,QAAS,YAAY,CAACA,EAAM,KAAK,KAAK,KACzE,EAAE,cAAcA,MAAU,OAAOA,EAAM,YAAa,YACpD,EAAE,WAAWA,MAAU,OAAOA,EAAM,SAAU,WAAiB,OAC5D;EAAE,MAAMA,EAAM;EAAM,UAAUA,EAAM;EAAU,OAAOA,EAAM;CAAM;AAC1E;AAGA,SAASC,EAAa,GAAiC;CACrD,IAAI,OAAOD,KAAU,aAAYA,GAAgB,OAAO;CACxD,IAAME,IACJ,YAAY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kBAACN,GAAD;KACE,WAAU;KACV,MAAK;KACL,SAAQ;KACR,UAAUZ,KAAWgB;KACrB,eAAe,KAAKM,EAAW;KAChC,UAAA;IAEO,CAAA,CACL;;GAENF,EAAO,SAASW,KACf,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACGX,EAAO,OAAO,eAAe;MAAE;MAAKW,EAAM,eAAe;MAAE;KAC3D;IACH,CAAA,GAAA,kBAACnB,GAAD;KACE,WAAU;KACV,MAAK;KACL,SAAQ;KACR,UAAUZ,KAAWgB;KACrB,eAAe,KAAKM,EAAW;KAE9B,UAAAN,IAAc,oBAAoB;IAC7B,CAAA,CACL;;GAENR,IACC,kBAACJ,GAAD,EAAsC,WAAU,GAA5BI,CAA4B,IAC9CR,IACF,kBAAC,KAAD;IAAG,MAAK;IAAS,WAAU;IAAmC,UAAA;GAE3D,CAAA,IACDD,IAAS,OACX,kBAAC,KAAD;IAAG,WAAU;IAAmC,UAAA;GAAmD,CAAA;EAE5F;;AAEf"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CombinedGraphQLErrors as e } from "../../../node_modules/@apollo/client/errors/CombinedGraphQLErrors.js";
|
|
2
|
+
import { useEventLatestCertificateEmailQuery as t, useQueueEventCertificateEmailMutation as n } from "../../../generated/wspace-operations.js";
|
|
3
|
+
import { useTr as r } from "../../../shared/hooks/useTr.js";
|
|
4
|
+
import { notify as i } from "../../lib/toast.js";
|
|
5
|
+
import { formatDateTime as a } from "../events/eventFormUtils.js";
|
|
6
|
+
import { useRef as o, useState as s } from "react";
|
|
7
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
import { Button as d, Dialog as f, DialogContent as p, DialogDescription as m, DialogHeader as h, DialogTitle as g } from "@burdenoff/fe-libs/ui";
|
|
9
|
+
// src/eventfullymanaged/pages/certificates/CertificateEmailControls.tsx
|
|
10
|
+
function _({ eventId: e, certificateId: n }) {
|
|
11
|
+
let a = r(), [o, c] = s(null), f = t({
|
|
12
|
+
variables: {
|
|
13
|
+
eventId: e,
|
|
14
|
+
certificateId: n
|
|
15
|
+
},
|
|
16
|
+
fetchPolicy: "no-cache",
|
|
17
|
+
notifyOnNetworkStatusChange: !0
|
|
18
|
+
}), p = o ?? f.data?.eventfullyManagedLatestCertificateEmailDelivery ?? null, m = async () => {
|
|
19
|
+
try {
|
|
20
|
+
let e = await f.refetch();
|
|
21
|
+
if (e.error || !e.data) throw Error("Email status was not confirmed.");
|
|
22
|
+
c(null);
|
|
23
|
+
} catch {
|
|
24
|
+
i.error(a("eventfullymanaged.certificates.emailStatusError", "Could not refresh the certificate email status."));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ u("section", {
|
|
28
|
+
className: "space-y-2 border-t border-border-seam pt-3",
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ l("h4", {
|
|
31
|
+
className: "font-medium",
|
|
32
|
+
children: a("eventfullymanaged.certificates.emailTitle", "Certificate email")
|
|
33
|
+
}),
|
|
34
|
+
p ? /* @__PURE__ */ l(v, { delivery: p }) : null,
|
|
35
|
+
f.loading ? /* @__PURE__ */ l("p", {
|
|
36
|
+
role: "status",
|
|
37
|
+
children: a("eventfullymanaged.certificates.emailStatusLoading", "Checking email status…")
|
|
38
|
+
}) : null,
|
|
39
|
+
f.error ? /* @__PURE__ */ l("p", {
|
|
40
|
+
role: "alert",
|
|
41
|
+
className: "text-status-error-text",
|
|
42
|
+
children: a("eventfullymanaged.certificates.emailStatusError", "Could not refresh the certificate email status.")
|
|
43
|
+
}) : null,
|
|
44
|
+
/* @__PURE__ */ u("div", {
|
|
45
|
+
className: "flex flex-wrap gap-2",
|
|
46
|
+
children: [/* @__PURE__ */ l(y, {
|
|
47
|
+
eventId: e,
|
|
48
|
+
certificateId: n,
|
|
49
|
+
previous: p,
|
|
50
|
+
disabled: f.loading || !!f.error,
|
|
51
|
+
onQueued: c
|
|
52
|
+
}), /* @__PURE__ */ l(d, {
|
|
53
|
+
type: "button",
|
|
54
|
+
variant: "outline",
|
|
55
|
+
disabled: f.loading,
|
|
56
|
+
onClick: () => void m(),
|
|
57
|
+
children: a("eventfullymanaged.certificates.emailRefresh", "Refresh email status")
|
|
58
|
+
})]
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function v({ delivery: e }) {
|
|
64
|
+
let t = r();
|
|
65
|
+
return /* @__PURE__ */ u("div", {
|
|
66
|
+
className: "space-y-1 text-sm",
|
|
67
|
+
"aria-live": "polite",
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ l("p", { children: t("eventfullymanaged.certificates.emailStatus", "Request status: {{status}}", { status: e.status }) }),
|
|
70
|
+
e.channelStatus ? /* @__PURE__ */ l("p", { children: t("eventfullymanaged.certificates.emailChannelStatus", "Email provider status: {{status}}", { status: e.channelStatus }) }) : null,
|
|
71
|
+
/* @__PURE__ */ l("p", { children: t("eventfullymanaged.certificates.emailRequestedAt", "Requested {{date}}", { date: a(e.createdAt) }) })
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function y({ eventId: t, certificateId: i, previous: a, disabled: _, onQueued: v }) {
|
|
76
|
+
let y = r(), [b, x] = s(!1), [S, C] = s(), w = o(null), [T, { loading: E }] = n({ refetchQueries: ["EventLatestCertificateEmail"] }), D = a?.status === "pending" || a?.status === "submitting", O = a ? y("eventfullymanaged.certificates.emailResend", "Re-send certificate email") : y("eventfullymanaged.certificates.emailSend", "Email certificate"), k = () => {
|
|
77
|
+
w.current?.previousDeliveryId !== (a?.id ?? null) && (w.current = null, C(void 0)), x(!0);
|
|
78
|
+
}, A = async () => {
|
|
79
|
+
if (!(E || D || _)) {
|
|
80
|
+
C(void 0);
|
|
81
|
+
try {
|
|
82
|
+
w.current ??= {
|
|
83
|
+
id: crypto.randomUUID(),
|
|
84
|
+
previousDeliveryId: a?.id ?? null
|
|
85
|
+
};
|
|
86
|
+
let e = await T({ variables: {
|
|
87
|
+
eventId: t,
|
|
88
|
+
certificateId: i,
|
|
89
|
+
requestId: w.current.id
|
|
90
|
+
} }), n = e.data?.eventfullyManagedQueueCertificateEmail;
|
|
91
|
+
if (e.error) throw e.error;
|
|
92
|
+
if (!n?.id) throw Error("Email request was not confirmed.");
|
|
93
|
+
w.current = null, v(n), x(!1);
|
|
94
|
+
} catch (t) {
|
|
95
|
+
let n = e.is(t) && t.errors.some(({ extensions: e }) => e?.code === "CONFLICT");
|
|
96
|
+
C(n ? y("eventfullymanaged.certificates.emailBindingError", "The original attendee binding is unavailable for this receipt. Download the PDF from the receipt.") : y("eventfullymanaged.certificates.emailQueueError", "Could not confirm the email request. Retry the same request."));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(d, {
|
|
101
|
+
type: "button",
|
|
102
|
+
disabled: _ || D,
|
|
103
|
+
onClick: k,
|
|
104
|
+
children: O
|
|
105
|
+
}), /* @__PURE__ */ l(f, {
|
|
106
|
+
open: b,
|
|
107
|
+
onOpenChange: (e) => {
|
|
108
|
+
E || x(e);
|
|
109
|
+
},
|
|
110
|
+
children: /* @__PURE__ */ u(p, { children: [
|
|
111
|
+
/* @__PURE__ */ u(h, { children: [/* @__PURE__ */ l(g, { children: O }), /* @__PURE__ */ l(m, { children: y("eventfullymanaged.certificates.emailHelp", "Queue the issued PDF for the email address on the attendee registration.") })] }),
|
|
112
|
+
a?.status === "unknown" ? /* @__PURE__ */ l("p", {
|
|
113
|
+
className: "text-sm",
|
|
114
|
+
children: y("eventfullymanaged.certificates.emailUnknown", "The previous request has no confirmed outcome. A second request may send another copy.")
|
|
115
|
+
}) : null,
|
|
116
|
+
S ? /* @__PURE__ */ l("p", {
|
|
117
|
+
role: "alert",
|
|
118
|
+
className: "text-status-error-text",
|
|
119
|
+
children: S
|
|
120
|
+
}) : null,
|
|
121
|
+
/* @__PURE__ */ u("div", {
|
|
122
|
+
className: "flex flex-wrap justify-end gap-2",
|
|
123
|
+
children: [/* @__PURE__ */ l(d, {
|
|
124
|
+
type: "button",
|
|
125
|
+
variant: "outline",
|
|
126
|
+
disabled: E,
|
|
127
|
+
onClick: () => x(!1),
|
|
128
|
+
children: y("eventfullymanaged.certificates.cancel", "Cancel")
|
|
129
|
+
}), /* @__PURE__ */ l(d, {
|
|
130
|
+
type: "button",
|
|
131
|
+
disabled: E || _ || D,
|
|
132
|
+
onClick: () => void A(),
|
|
133
|
+
children: E ? y("eventfullymanaged.certificates.emailQueueing", "Queueing…") : y("eventfullymanaged.certificates.emailConfirm", "Queue email")
|
|
134
|
+
})]
|
|
135
|
+
})
|
|
136
|
+
] })
|
|
137
|
+
})] });
|
|
138
|
+
}
|
|
139
|
+
export { _ as CertificateEmailControls };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=CertificateEmailControls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CertificateEmailControls.js","names":["_Fragment","CertificateEmailControls","tr","useTr","queued","setQueued","useState","latest","useEventLatestCertificateEmailQuery","delivery","refresh","result","CertificateEmailStatus","CertificateEmailRequest","Button","formatDateTime","open","setOpen","errorMessage","setErrorMessage","request","useRef","queue","useQueueEventCertificateEmailMutation","sending","previous","label","openConfirmation","submit","disabled","onQueued","error","missingBinding","CombinedGraphQLErrors","extensions","Fragment","Dialog","loading","next","DialogContent","DialogHeader","DialogTitle","DialogDescription"],"sources":["../../../../src/eventfullymanaged/pages/certificates/CertificateEmailControls.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { CombinedGraphQLErrors } from '@apollo/client/errors';\nimport { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@burdenoff/fe-libs/ui';\nimport {\n useEventLatestCertificateEmailQuery,\n useQueueEventCertificateEmailMutation,\n type EventCertificateEmailFieldsFragment,\n} from '../../../generated/wspace-operations';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { notify } from '../../lib/toast';\nimport { formatDateTime } from '../events/eventFormUtils';\n\ntype Delivery = EventCertificateEmailFieldsFragment;\ntype DeliveryScope = { eventId: string; certificateId: string };\n\nexport function CertificateEmailControls({ eventId, certificateId }: DeliveryScope) {\n const tr = useTr();\n const [queued, setQueued] = useState<Delivery | null>(null);\n const latest = useEventLatestCertificateEmailQuery({\n variables: { eventId, certificateId },\n fetchPolicy: 'no-cache',\n notifyOnNetworkStatusChange: true,\n });\n const delivery: Delivery | null = queued ?? latest.data?.eventfullyManagedLatestCertificateEmailDelivery ?? null;\n\n const refresh = async () => {\n try {\n const result = await latest.refetch();\n if (result.error || !result.data) throw new Error('Email status was not confirmed.');\n setQueued(null);\n } catch {\n notify.error(\n tr('eventfullymanaged.certificates.emailStatusError', 'Could not refresh the certificate email status.')\n );\n }\n };\n\n return (\n <section className=\"space-y-2 border-t border-border-seam pt-3\">\n <h4 className=\"font-medium\">{tr('eventfullymanaged.certificates.emailTitle', 'Certificate email')}</h4>\n {delivery ? <CertificateEmailStatus delivery={delivery} /> : null}\n {latest.loading ? (\n <p role=\"status\">{tr('eventfullymanaged.certificates.emailStatusLoading', 'Checking email status…')}</p>\n ) : null}\n {latest.error ? (\n <p role=\"alert\" className=\"text-status-error-text\">\n {tr('eventfullymanaged.certificates.emailStatusError', 'Could not refresh the certificate email status.')}\n </p>\n ) : null}\n <div className=\"flex flex-wrap gap-2\">\n <CertificateEmailRequest\n eventId={eventId}\n certificateId={certificateId}\n previous={delivery}\n disabled={latest.loading || Boolean(latest.error)}\n onQueued={setQueued}\n />\n <Button type=\"button\" variant=\"outline\" disabled={latest.loading} onClick={() => void refresh()}>\n {tr('eventfullymanaged.certificates.emailRefresh', 'Refresh email status')}\n </Button>\n </div>\n </section>\n );\n}\n\nfunction CertificateEmailStatus({ delivery }: { delivery: Delivery }) {\n const tr = useTr();\n return (\n <div className=\"space-y-1 text-sm\" aria-live=\"polite\">\n <p>\n {tr('eventfullymanaged.certificates.emailStatus', 'Request status: {{status}}', { status: delivery.status })}\n </p>\n {delivery.channelStatus ? (\n <p>\n {tr('eventfullymanaged.certificates.emailChannelStatus', 'Email provider status: {{status}}', {\n status: delivery.channelStatus,\n })}\n </p>\n ) : null}\n <p>\n {tr('eventfullymanaged.certificates.emailRequestedAt', 'Requested {{date}}', {\n date: formatDateTime(delivery.createdAt),\n })}\n </p>\n </div>\n );\n}\n\nfunction CertificateEmailRequest({\n eventId,\n certificateId,\n previous,\n disabled,\n onQueued,\n}: DeliveryScope & {\n previous: Delivery | null;\n disabled: boolean;\n onQueued: (delivery: Delivery) => void;\n}) {\n const tr = useTr();\n const [open, setOpen] = useState(false);\n const [errorMessage, setErrorMessage] = useState<string>();\n const request = useRef<{ id: string; previousDeliveryId: string | null } | null>(null);\n const [queue, { loading }] = useQueueEventCertificateEmailMutation({\n refetchQueries: ['EventLatestCertificateEmail'],\n });\n const sending = previous?.status === 'pending' || previous?.status === 'submitting';\n const label = previous\n ? tr('eventfullymanaged.certificates.emailResend', 'Re-send certificate email')\n : tr('eventfullymanaged.certificates.emailSend', 'Email certificate');\n\n const openConfirmation = () => {\n if (request.current?.previousDeliveryId !== (previous?.id ?? null)) {\n request.current = null;\n setErrorMessage(undefined);\n }\n setOpen(true);\n };\n\n const submit = async () => {\n if (loading || sending || disabled) return;\n setErrorMessage(undefined);\n try {\n request.current ??= { id: crypto.randomUUID(), previousDeliveryId: previous?.id ?? null };\n const result = await queue({ variables: { eventId, certificateId, requestId: request.current.id } });\n const delivery = result.data?.eventfullyManagedQueueCertificateEmail;\n if (result.error) throw result.error;\n if (!delivery?.id) throw new Error('Email request was not confirmed.');\n request.current = null;\n onQueued(delivery);\n setOpen(false);\n } catch (error) {\n const missingBinding =\n CombinedGraphQLErrors.is(error) && error.errors.some(({ extensions }) => extensions?.code === 'CONFLICT');\n setErrorMessage(\n missingBinding\n ? tr(\n 'eventfullymanaged.certificates.emailBindingError',\n 'The original attendee binding is unavailable for this receipt. Download the PDF from the receipt.'\n )\n : tr(\n 'eventfullymanaged.certificates.emailQueueError',\n 'Could not confirm the email request. Retry the same request.'\n )\n );\n }\n };\n\n return (\n <>\n <Button type=\"button\" disabled={disabled || sending} onClick={openConfirmation}>\n {label}\n </Button>\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!loading) setOpen(next);\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{label}</DialogTitle>\n <DialogDescription>\n {tr(\n 'eventfullymanaged.certificates.emailHelp',\n 'Queue the issued PDF for the email address on the attendee registration.'\n )}\n </DialogDescription>\n </DialogHeader>\n {previous?.status === 'unknown' ? (\n <p className=\"text-sm\">\n {tr(\n 'eventfullymanaged.certificates.emailUnknown',\n 'The previous request has no confirmed outcome. A second request may send another copy.'\n )}\n </p>\n ) : null}\n {errorMessage ? (\n <p role=\"alert\" className=\"text-status-error-text\">\n {errorMessage}\n </p>\n ) : null}\n <div className=\"flex flex-wrap justify-end gap-2\">\n <Button type=\"button\" variant=\"outline\" disabled={loading} onClick={() => setOpen(false)}>\n {tr('eventfullymanaged.certificates.cancel', 'Cancel')}\n </Button>\n <Button type=\"button\" disabled={loading || disabled || sending} onClick={() => void submit()}>\n {loading\n ? tr('eventfullymanaged.certificates.emailQueueing', 'Queueing…')\n : tr('eventfullymanaged.certificates.emailConfirm', 'Queue email')}\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n </>\n );\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgBC,EAAyB,EAAE,YAAS,oBAAgC;CAClF,IAAMC,IAAKC,EAAM,GACX,CAACC,GAAQC,KAAaC,EAA0B,IAAI,GACpDC,IAASC,EAAoC;EACjD,WAAW;GAAE;GAAS;EAAc;EACpC,aAAa;EACb,6BAA6B;CAC/B,CAAC,GACKC,IAA4BL,KAAUG,EAAO,MAAM,mDAAmD,MAEtGG,IAAU,YAAY;EAC1B,IAAI;GACF,IAAMC,IAAS,MAAMJ,EA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