Redesign Phases 3-6: multi-event model, APPE Admin, Convivo App behaviors, APPE branding

- Phase 3: new migration 20260824000000_redesign.sql (contacts/events/registrations/sponsors, slot types, session speakers + feedback/material), seed rewrite
- Phase 4: APPE Admin rebrand + Contacts/Registrations/Sponsors/Schedule/Activity/Events views
- Phase 5: Convivo App (24h login, 5s polling, QR type badge, red dot, speaker material)
- Phase 6: APPE favicon + PWA icons for both apps
- Docs: schema/rpcs/rls/seed/screens/api-client/admin-app/architecture/next-steps/README/roadmap updated

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:
committed 2026-08-23 02:53:16 +02:00
1 parent 2f53d47578
commit 7605c9bbf4
64 files changed
+4593 -1371

No files matched your search

+29 -30
View File
@@ -1,9 +1,9 @@
import { createContext, useContext, useEffect, useState, type ReactNode } from 'react';
import { supabase } from '../lib/supabase';
import type { Profile } from '../lib/types';
import type { Contact } from '../lib/types';
interface AuthState {
profile: Profile | null;
contact: Contact | null;
loading: boolean;
signIn: (email: string, qrToken: string) => Promise<void>;
signOut: () => Promise<void>;
@@ -11,11 +11,23 @@ interface AuthState {
const AuthContext = createContext<AuthState | null>(null);
// Load the current user's contact row. Returns null if it doesn't exist or the
// contact is not an admin (this is an admin-only app).
async function loadAdminContact(email: string): Promise<Contact | null> {
const { data } = await supabase
.from('contacts')
.select('*')
.eq('email', email)
.maybeSingle();
const c = data as Contact | null;
return c && c.is_admin ? c : null;
}
export function AuthProvider({ children }: { children: ReactNode }) {
const [profile, setProfile] = useState<Profile | null>(null);
const [contact, setContact] = useState<Contact | null>(null);
const [loading, setLoading] = useState(true);
// On mount: restore any existing session and load the profile. If the
// On mount: restore any existing session and load the contact. If the
// session belongs to a non-admin, sign out immediately (admin-only app).
useEffect(() => {
let cancelled = false;
@@ -27,14 +39,10 @@ export function AuthProvider({ children }: { children: ReactNode }) {
if (!cancelled) setLoading(false);
return;
}
const { data: prof } = await supabase
.from('profiles')
.select('*')
.eq('id', session.user.id)
.maybeSingle();
const c = session.user.email ? await loadAdminContact(session.user.email) : null;
if (cancelled) return;
if (prof && prof.role === 'admin') {
setProfile(prof as Profile);
if (c) {
setContact(c);
} else {
// Not an admin — clear the session.
await supabase.auth.signOut();
@@ -46,19 +54,15 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const { data: sub } = supabase.auth.onAuthStateChange(async (_event, session) => {
if (!session) {
setProfile(null);
setContact(null);
return;
}
const { data: prof } = await supabase
.from('profiles')
.select('*')
.eq('id', session.user.id)
.maybeSingle();
if (prof && prof.role === 'admin') {
setProfile(prof as Profile);
const c = session.user.email ? await loadAdminContact(session.user.email) : null;
if (c) {
setContact(c);
} else {
await supabase.auth.signOut();
setProfile(null);
setContact(null);
}
});
@@ -75,27 +79,22 @@ export function AuthProvider({ children }: { children: ReactNode }) {
});
if (error) throw new Error(error.message);
const { data: prof } = await supabase
.from('profiles')
.select('*')
.eq('id', data.user.id)
.maybeSingle();
if (!prof || prof.role !== 'admin') {
const c = data.user.email ? await loadAdminContact(data.user.email) : null;
if (!c) {
// Signed in, but not an admin — reject and sign out.
await supabase.auth.signOut();
throw new Error('This account is not an admin.');
}
setProfile(prof as Profile);
setContact(c);
}
async function signOut() {
await supabase.auth.signOut();
setProfile(null);
setContact(null);
}
return (
<AuthContext.Provider value={{ profile, loading, signIn, signOut }}>
<AuthContext.Provider value={{ contact, loading, signIn, signOut }}>
{children}
</AuthContext.Provider>
);