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
+3
View File
@@ -33,6 +33,9 @@ export type User = {
* the "Change password" modal and the "Set a password" flow.
*/
has_password: boolean;
/** True when an admin has linked this account to the disciples directory —
* one of Śrīla Prabhupāda's own initiated disciples. Admin-set only. */
is_direct_disciple?: boolean;
/** Account country as an ISO-3166-1 alpha-2 code (e.g. "IN"), or null
* when unknown. Captured best-effort at signup; user-editable. */
country: string | null;
+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. */
+8 -1
View File
@@ -192,6 +192,9 @@ export type PublicProfile = {
follower_count: number;
following_count: number;
relationship: RelationshipState | null;
/** True when an admin has linked this account to the disciples directory —
* i.e. one of Śrīla Prabhupāda's own initiated disciples. */
is_direct_disciple?: boolean;
public_collections: Collection[];
};
@@ -698,7 +701,11 @@ export const notifications = {
// ─── Notification preferences ──────────────────────────────────────────
export type PrefEvent = "follows" | "post_interactions" | "sadhna_reminders";
export type PrefEvent =
| "follows"
| "post_interactions"
| "sadhna_reminders"
| "community";
export type PrefChannel = "in_app" | "email" | "push";
/** event → channel → enabled, as resolved by the BFF (defaults on). */
export type NotificationPrefs = Record<PrefEvent, Record<PrefChannel, boolean>>;