feat: disciple highlight

This commit is contained in:
gosangam
2026-08-07 22:47:04 +05:30
parent 1984797ad3
commit 274c735b4d
13 changed files with 348 additions and 64 deletions
+49
View File
@@ -41,6 +41,19 @@ export type YearGroup = {
export type SuffixFilter = "all" | "Dasa" | "Devi Dasi";
/**
* A disciple who has a platform account, linked by an admin.
*
* The disciple records live in Mongo while accounts live in Postgres, so the
* link is resolved server-side by the BFF and handed over as this flat pair.
*/
export type DiscipleLink = {
discipleId: string;
handle: string;
name: string;
avatarURL: string | null;
};
// --- BFF response types (snake_case from Go API) ---
type BffDisciple = {
@@ -76,6 +89,42 @@ function mapDisciple(d: BffDisciple): DiscipleSummary {
};
}
// --- Linked platform accounts ---
type BffDiscipleLink = {
disciple_id: string;
handle: string;
name: string;
avatar_url: string | null;
};
/**
* Get every disciple who has a platform account.
*
* Deliberately unpaged — only Śrīla Prabhupāda's own disciples are ever
* linked, so this is a few dozen rows at most and the browser fetches the
* whole set once to highlight the matching cards.
*
* Fails soft: the highlight is decorative, so a BFF hiccup (or a rolling
* deploy where the frontend is ahead of the API) must not take the whole
* directory page down with it. `bff` already maps 404 → null; here we also
* swallow 5xx and network errors and fall back to "no highlights".
*/
export async function getDiscipleLinks(): Promise<DiscipleLink[]> {
try {
const links = await bffList<BffDiscipleLink>("/disciples/linked");
return links.map((l) => ({
discipleId: l.disciple_id,
handle: l.handle,
name: l.name,
avatarURL: l.avatar_url ?? null,
}));
} catch (err) {
console.error("getDiscipleLinks failed; rendering without highlights", err);
return [];
}
}
// --- Count ---
/** Get total number of disciples in the collection. */