Phase 2: Admin console (admin.appe.at)
A desktop-first React app for organizers, guarded to the admin role. Backend (supabase/migrations/20260823000000_admin_app.sql): - Admin-only SELECT policies on preferences, connections, feedback - reset_qr_token RPC: regenerates a lanyard token, re-hashes it as the Auth password (old token stops working), and clears the attendee's sessions to force re-login App (apps/admin, port 3001): - Login: same QR+email flow, but non-admin sessions are rejected - Dashboard: live stats + top points + recent activity - Attendees: search, edit name/company/role, reset QR, adjust points - Schedule: manage slots + sessions (create/edit/delete) - Activity: check-ins / connections / feedback tables - Same-origin proxy (Vite dev / nginx in Docker), same design tokens Docker + scripts: - convivo-admin service in docker-compose.yml (:3001) - admin:dev / admin:build root scripts - fixed db:reset script (supabase reset -> supabase db reset) Docs: new frontend/admin-app.md; updated architecture, rls, rpcs, docker, next-steps, and READMEs. Verified: build clean, all views + flows browser-tested, Docker build + proxy + login + admin guard confirmed. DB reset to clean seed.
This commit is contained in:
1 parent
0cbfb25714
commit
cf70f39903
45 files changed
+4425
-87
No files matched your search
@@ -0,0 +1,95 @@
|
||||
import { useState } from 'react';
|
||||
import { AuthProvider, useAuth } from './context/AuthContext';
|
||||
import { ToastProvider } from './context/ToastContext';
|
||||
import { Login } from './screens/Login';
|
||||
import { Dashboard } from './views/Dashboard';
|
||||
import { Attendees } from './views/Attendees';
|
||||
import { Schedule } from './views/Schedule';
|
||||
import { Activity } from './views/Activity';
|
||||
import { Spinner } from './components/ui';
|
||||
|
||||
type View = 'dashboard' | 'attendees' | 'schedule' | 'activity';
|
||||
|
||||
const NAV: { id: View; label: string; ico: string }[] = [
|
||||
{ id: 'dashboard', label: 'Dashboard', ico: '📊' },
|
||||
{ id: 'attendees', label: 'Attendees', ico: '👥' },
|
||||
{ id: 'schedule', label: 'Schedule', ico: '🗓️' },
|
||||
{ id: 'activity', label: 'Activity', ico: '⚡' },
|
||||
];
|
||||
|
||||
function Shell() {
|
||||
const { profile, loading, signOut } = useAuth();
|
||||
const [view, setView] = useState<View>('dashboard');
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="loading-screen">
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!profile) return <Login />;
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<aside className="sidebar">
|
||||
<div className="brand">
|
||||
<div className="logo">C</div>
|
||||
<div>
|
||||
<div className="name">Convivo</div>
|
||||
<div className="sub">Admin Console</div>
|
||||
</div>
|
||||
</div>
|
||||
<nav className="nav">
|
||||
{NAV.map((n) => (
|
||||
<button
|
||||
key={n.id}
|
||||
className={`nav-item ${view === n.id ? 'active' : ''}`}
|
||||
onClick={() => setView(n.id)}
|
||||
>
|
||||
<span className="ico">{n.ico}</span>
|
||||
{n.label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
<div className="sidebar-foot">
|
||||
<div className="admin-card">
|
||||
<span className="avatar" style={{ width: 36, height: 36, fontSize: 13, background: '#d50000' }}>
|
||||
{profile.full_name
|
||||
.split(' ')
|
||||
.map((w) => w[0])
|
||||
.slice(0, 2)
|
||||
.join('')
|
||||
.toUpperCase()}
|
||||
</span>
|
||||
<div className="who">
|
||||
<div className="n">{profile.full_name}</div>
|
||||
<div className="e">{profile.email}</div>
|
||||
</div>
|
||||
</div>
|
||||
<button className="signout" onClick={signOut}>
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main className="content">
|
||||
{view === 'dashboard' && <Dashboard onNavigate={setView} />}
|
||||
{view === 'attendees' && <Attendees />}
|
||||
{view === 'schedule' && <Schedule />}
|
||||
{view === 'activity' && <Activity />}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function App() {
|
||||
return (
|
||||
<ToastProvider>
|
||||
<AuthProvider>
|
||||
<Shell />
|
||||
</AuthProvider>
|
||||
</ToastProvider>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user