refine admin leaderboard experience
This commit is contained in:
1 parent
fe0ede178e
commit
88c83b4dd7
13 files changed
+754
-405
No files matched your search
@@ -61,6 +61,22 @@ export interface CitationDisplayUpdate {
|
||||
cleanup_words?: string[];
|
||||
}
|
||||
|
||||
export interface LeaderboardSettings {
|
||||
exclude_user_ids: string[];
|
||||
include_scheduled: boolean;
|
||||
include_admins: boolean;
|
||||
include_failed: boolean;
|
||||
cleanup_system_questions: boolean;
|
||||
}
|
||||
|
||||
export interface LeaderboardSettingsUpdate {
|
||||
exclude_user_ids?: string[];
|
||||
include_scheduled?: boolean;
|
||||
include_admins?: boolean;
|
||||
include_failed?: boolean;
|
||||
cleanup_system_questions?: boolean;
|
||||
}
|
||||
|
||||
export async function loadPrivateSquareStatus(): Promise<PrivateSquareStatus> {
|
||||
const response = await apiFetch(
|
||||
`${getBackendBaseURL()}/api/system-settings/private-square`,
|
||||
@@ -127,6 +143,36 @@ export async function loadCitationDisplaySettings(): Promise<CitationDisplaySett
|
||||
return (await response.json()) as CitationDisplaySettings;
|
||||
}
|
||||
|
||||
export async function loadLeaderboardSettings(): Promise<LeaderboardSettings> {
|
||||
const response = await apiFetch(
|
||||
`${getBackendBaseURL()}/api/system-settings/leaderboard`,
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to load leaderboard settings: ${response.status}`);
|
||||
}
|
||||
return (await response.json()) as LeaderboardSettings;
|
||||
}
|
||||
|
||||
export async function updateLeaderboardSettings(
|
||||
body: LeaderboardSettingsUpdate,
|
||||
): Promise<LeaderboardSettings> {
|
||||
const response = await apiFetch(
|
||||
`${getBackendBaseURL()}/api/system-settings/leaderboard`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
},
|
||||
);
|
||||
if (!response.ok) {
|
||||
const detail = await response
|
||||
.json()
|
||||
.catch(() => ({ detail: "Failed to update leaderboard settings" }));
|
||||
throw new Error(detail.detail ?? "Failed to update leaderboard settings");
|
||||
}
|
||||
return (await response.json()) as LeaderboardSettings;
|
||||
}
|
||||
|
||||
export async function updateCitationDisplaySettings(
|
||||
body: CitationDisplayUpdate,
|
||||
): Promise<CitationDisplaySettings> {
|
||||
|
||||
Reference in new issue
Block a user