Admin password login + attendee profile self-service
- contacts.password: admin-only APPE Admin login password (event-independent); must match the bcrypt hash in auth.users.encrypted_password (set in Supabase). - APPE Admin login is now email + password (was QR token). - update_my_profile RPC (security definer, scoped to current_email()): attendees set their LinkedIn URL + show_email / show_linkedin toggles from the Profile. - Convivo Profile gains a 'Profile settings' card (LinkedIn + 2 toggles + Save). - Visibility enforced server-side in the public projection (linkedin nulled when show_linkedin off, email omitted when show_email off). - Seed: admin password appe-admin-2026; staff keep QR tokens as auth passwords. - Docs updated (schema, rpcs, seed, admin-app, screens, api-client, architecture, next-steps, README, docker-compose).
This commit is contained in:
1 parent
b52d8ab007
commit
8b1130f078
19 files changed
+290
-59
No files matched your search
@@ -1,9 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { getMyPointsLog } from '../lib/api';
|
||||
import { getMyPointsLog, updateMyProfile } from '../lib/api';
|
||||
import { capWords } from '../lib/time';
|
||||
import type { PointsLogRow } from '../lib/types';
|
||||
import { Avatar, QrImage, Spinner } from '../components/ui';
|
||||
import { Avatar, QrImage, Spinner, Toggle } from '../components/ui';
|
||||
import { useToast } from '../context/ToastContext';
|
||||
|
||||
const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
|
||||
checkin: 'Session check-ins',
|
||||
@@ -13,10 +14,17 @@ const CATEGORY_LABEL: Record<PointsLogRow['category'], string> = {
|
||||
};
|
||||
|
||||
export function Profile() {
|
||||
const { contact, registration, signOut } = useAuth();
|
||||
const { contact, registration, signOut, refresh } = useAuth();
|
||||
const { toast } = useToast();
|
||||
const [log, setLog] = useState<PointsLogRow[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// Profile self-service (LinkedIn + visibility).
|
||||
const [linkedin, setLinkedin] = useState(contact?.linkedin_url ?? '');
|
||||
const [showEmail, setShowEmail] = useState(contact?.show_email ?? false);
|
||||
const [showLinkedin, setShowLinkedin] = useState(contact?.show_linkedin ?? false);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const email = contact?.email ?? '';
|
||||
|
||||
useEffect(() => {
|
||||
@@ -42,6 +50,23 @@ export function Profile() {
|
||||
const totals: Record<string, number> = {};
|
||||
for (const l of log) totals[l.category] = (totals[l.category] ?? 0) + l.delta;
|
||||
|
||||
async function saveProfile() {
|
||||
setSaving(true);
|
||||
try {
|
||||
await updateMyProfile({
|
||||
linkedin_url: linkedin.trim() || null,
|
||||
show_email: showEmail,
|
||||
show_linkedin: showLinkedin,
|
||||
});
|
||||
await refresh();
|
||||
toast('Profile updated', 'ok');
|
||||
} catch (e) {
|
||||
toast(e instanceof Error ? e.message : 'Could not save profile', 'err');
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="screen">
|
||||
<div className="h1">Profile</div>
|
||||
@@ -68,6 +93,30 @@ export function Profile() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="h2" style={{ marginBottom: 6 }}>Profile settings</div>
|
||||
<div className="muted small" style={{ marginBottom: 12 }}>
|
||||
Choose what other attendees can see on your profile.
|
||||
</div>
|
||||
<div style={{ marginBottom: 12 }}>
|
||||
<div className="muted small" style={{ marginBottom: 4 }}>LinkedIn</div>
|
||||
<input
|
||||
className="input"
|
||||
type="url"
|
||||
placeholder="https://linkedin.com/in/you"
|
||||
value={linkedin}
|
||||
onChange={(e) => setLinkedin(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginBottom: 14 }}>
|
||||
<Toggle checked={showEmail} onChange={setShowEmail} label="Show my email" />
|
||||
<Toggle checked={showLinkedin} onChange={setShowLinkedin} label="Show my LinkedIn" />
|
||||
</div>
|
||||
<button className="btn primary" disabled={saving} onClick={() => void saveProfile()}>
|
||||
{saving ? 'Saving…' : 'Save profile'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="card">
|
||||
<div className="h2" style={{ marginBottom: 6 }}>Points breakdown</div>
|
||||
{loading ? (
|
||||
|
||||
Reference in new issue
Block a user