| 1 | /** |
| 2 | * The Invites page: every invitation sent to an address, to find and |
| 3 | * revoke one. Anyone may register, so there is no waitlist, no allowance |
| 4 | * and no shared link to manage. No Workers imports, so it can be tested |
| 5 | * under Node. Identity checks everything again. |
| 6 | */ |
| 7 | |
| 8 | /** The page's address, with its search. */ |
| 9 | export function invitesHref(params: Record<string, string | null | undefined> = {}): string { |
| 10 | const search = new URLSearchParams(); |
| 11 | for (const [key, value] of Object.entries(params)) if (value) search.set(key, value); |
| 12 | const query = search.toString(); |
| 13 | return query ? `/invites?${query}` : "/invites"; |
| 14 | } |
| 15 | |
| 16 | /** The flash messages the page redirects back with (`?done=`). */ |
| 17 | export const INVITES_DONE: Record<string, string> = { |
| 18 | revoked: "Invite revoked. It stops working at once.", |
| 19 | }; |
| 20 | |
| 21 | /** The flash for `?done=`. */ |
| 22 | export function doneMessage(done: string | null): string | null { |
| 23 | return done ? (INVITES_DONE[done] ?? null) : null; |
| 24 | } |
| 25 | |
| 26 | /** What an account made with a shared link, before registration opened, says about where it came from. */ |
| 27 | export function joinedThrough(label: string): string { |
| 28 | return `Joined through ${label}`; |
| 29 | } |