/* ═══════════════════════════════════════════════════════════════
ADMIN: PROFILE ACCOUNTS (Data → Profile accounts, admins and up)
Profile accounts (076) are by invite: an email added here gets an
account with no password and a link to set one (or to sign in
with Google under that email). The link is shown once, to copy;
Email invite sends a fresh one through Gmail and shows it too
(the one before stops working). For an account already set up,
the same link is a way back in when a password is forgotten.
Then: the claims waiting (someone asking to be a People record),
and each account's record, Discord and whether it's on. Server
side: server/src/routes/profiles.js. Admin accounts (viewer and
up) are the Panel's, not this page's.
═══════════════════════════════════════════════════════════════ */
import { useCallback, useEffect, useId, useState, type FormEvent } from "react";
import { ApiError, del, get, patch, post } from "../../lib/api.ts";
import { preview } from "../../lib/text.ts";
const MUTED = "var(--color-muted)";
const button =
"btn border border-brand px-3 py-1.5 text-sm text-link transition-colors hover:bg-tint disabled:cursor-default disabled:opacity-50";
const primary =
"btn bg-action px-5 py-2.5 text-white transition-colors hover:bg-action-hover disabled:bg-muted/25";
const danger =
"btn border border-danger/40 px-3 py-1.5 text-sm text-danger transition-colors hover:bg-danger-tint disabled:opacity-50";
const input =
"w-full border border-muted/25 bg-surface px-3 py-2 text-sm text-body outline-none focus:border-brand focus:ring-2 focus:ring-brand/25";
type Account = {
id: number;
email: string;
name: string | null;
is_active: number;
created_at: string;
last_login_at: string | null;
invited_at: string | null;
invite_expires_at: string | null;
invite_open: number;
signed_up: number;
person_id: string | null;
person_name: string | null;
discord_id: string | null;
discord_name: string | null;
};
type Claim = {
id: number;
account_id: number;
email: string;
name: string | null;
person_id: string;
person_name: string;
message: string | null;
created_at: string;
};
const message = (err: unknown) => (err instanceof ApiError ? err.message : "Couldn't reach the server.");
const day = (value: string | null) => (value ? value.slice(0, 10) : "-");
/* A link to copy, shown once. */
function LinkBox({ link, note }: { link: string; note: string }) {
const [copied, setCopied] = useState(false);
return (
They link it themselves from their profile; this overrides it. The ID is the long number from Discord (Developer Mode, then Copy User ID), eg. 80351110224678912. Blank unlinks it.