diff --git a/src/pages/account.astro b/src/pages/account.astro new file mode 100644 index 0000000..468d8f3 --- /dev/null +++ b/src/pages/account.astro @@ -0,0 +1,296 @@ +--- +import AppLayout from '../layouts/AppLayout.astro'; +import { updateUserProfile } from '../lib/db'; + +const user = Astro.locals.user; +let success = false; +let error: string | null = null; + +if (Astro.request.method === 'POST') { + const data = await Astro.request.formData(); + const name = String(data.get('name') ?? '').trim(); + const bio = String(data.get('bio') ?? '').trim(); + + if (name.length < 2) { + error = 'Name must be at least 2 characters.'; + } else if (bio.length > 280) { + error = 'Bio must be 280 characters or fewer.'; + } else { + updateUserProfile(user.id, name, bio); + return Astro.redirect('/account?saved=1'); + } +} + +const saved = Astro.url.searchParams.get('saved') === '1'; +--- + +
+ + + +
+ {saved && ( +

Profile updated.

+ )} + {error && ( + + )} + + + + +
+ +
+
+ + diff --git a/src/pages/participants.astro b/src/pages/participants.astro new file mode 100644 index 0000000..0942f45 --- /dev/null +++ b/src/pages/participants.astro @@ -0,0 +1,185 @@ +--- +import AppLayout from '../layouts/AppLayout.astro'; +import { getAllUsersPublic } from '../lib/db'; +import type { UserPublic, Role } from '../lib/db'; + +const user = Astro.locals.user; + +const allUsers = getAllUsersPublic().filter((u) => u.active); + +// Group by organisation +const orgs = new Map(); +for (const u of allUsers) { + if (!orgs.has(u.organisation)) orgs.set(u.organisation, []); + orgs.get(u.organisation)!.push(u); +} + +const roleLabels: Record = { + pilot: 'Pilot', + cab: 'CAB', + fenja: 'Fenja', +}; + +const roleColors: Record = { + pilot: 'var(--pigment-copper)', + cab: 'var(--pigment-indigo)', + fenja: 'var(--secondary)', +}; +--- + +
+ + + +
+ {[...orgs.entries()].map(([orgName, members]) => ( +
+

{orgName}

+
    + {members.map((member) => ( +
  • +
    + {member.name} + + {roleLabels[member.role]} + +
    + {member.bio && ( +

    {member.bio}

    + )} + {member.id === user.id && ( + + Edit your bio + + )} +
  • + ))} +
+
+ ))} +
+ +
+
+ +