feat: disciple highlight
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user