feat: disciple link

This commit is contained in:
gosangam
2026-08-07 22:46:41 +05:30
parent 5c9a689306
commit 7ff5610477
3 changed files with 332 additions and 0 deletions
+34
View File
@@ -133,6 +133,22 @@ export type AdminUser = {
bookmark_limit: number;
public_collection_limit: number;
private_collection_limit: number;
/** Direct-disciple link: the Mongo disciple id this account is linked to,
* and that disciple's name (hydrated server-side). Both null when the
* account isn't one of Śrīla Prabhupāda's direct disciples. */
disciple_id: string | null;
disciple_name: string | null;
};
/** One option in the direct-disciple picker. `linked_handle` is the @handle of
* the account already linked to this disciple — non-null means "taken". */
export type AdminDisciple = {
id: string;
initiated_name: string;
suffix: string;
initiation_date: string | null;
initiation_place: string | null;
linked_handle: string | null;
};
/** Per-user save-limit override payload. null = reset that limit to the plan
@@ -287,6 +303,24 @@ export const api = {
body: JSON.stringify(limits),
});
},
/** Search Śrīla Prabhupāda's disciples for the link picker. An empty query
* returns the first page alphabetically. */
async disciples(q: string, limit = 25): Promise<AdminDisciple[]> {
const { data } = await call<AdminDisciple[]>(
`/admin/disciples${qs({ q, limit })}`,
);
return data ?? [];
},
/** Mark a user as a direct disciple. Re-linking moves an existing link. */
linkDisciple(userId: string, discipleId: string) {
return call(`/admin/users/${userId}/disciple`, {
method: "POST",
body: JSON.stringify({ disciple_id: discipleId }),
});
},
unlinkDisciple(userId: string) {
return call(`/admin/users/${userId}/disciple`, { method: "DELETE" });
},
posts(q: string, limit: number, offset: number) {
return listed<AdminPost>(`/admin/posts${qs({ q, limit, offset })}`);
},