Files
Convivo/apps/convivo/src/context/ToastContext.tsx
T
63aa4ecfc8 Phase 0 + 1: Dockerized Supabase core + attendee PWA
Phase 0 — Supabase core (Docker via CLI):
- Schema: profiles, slots, sessions, preferences, connections, checkins,
  feedback, leaderboard (Realtime mirror), points_log
- RLS on every table; transactional security-definer points RPCs
- Seed: 6 slots, 18 sessions, 13 demo users (QR token as auth password)

Phase 1 — Attendee web PWA (React + Vite + TS):
- Login via QR token + email (GoTrue, no email sent)
- Home, Agenda, Scan/Connect, staff Check-in, Feedback, live Leaderboard, Profile
- Same-origin proxy to Supabase (Vite dev / nginx in Docker)
- Docker: multi-stage build -> nginx sidecar on the Supabase network

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]>
2026-08-22 16:10:59 +02:00

37 lines
1.1 KiB
TypeScript

import { createContext, useCallback, useContext, useRef, useState, type ReactNode } from 'react';
type ToastType = '' | 'ok' | 'err';
interface ToastContextValue {
toast: (msg: string, type?: ToastType) => void;
}
const ToastContext = createContext<ToastContextValue | null>(null);
export function ToastProvider({ children }: { children: ReactNode }) {
const [msg, setMsg] = useState('');
const [type, setType] = useState<ToastType>('');
const [show, setShow] = useState(false);
const timer = useRef<number | undefined>(undefined);
const toast = useCallback((text: string, t: ToastType = '') => {
setMsg(text);
setType(t);
setShow(true);
window.clearTimeout(timer.current);
timer.current = window.setTimeout(() => setShow(false), 2600);
}, []);
return (
<ToastContext.Provider value={{ toast }}>
{children}
<div className={`toast ${show ? 'show' : ''} ${type}`}>{msg}</div>
</ToastContext.Provider>
);
}
export function useToast(): ToastContextValue {
const ctx = useContext(ToastContext);
if (!ctx) throw new Error('useToast must be used within ToastProvider');
return ctx;
}