Began implementation for getting promotion history

This commit is contained in:
2025-12-16 22:28:32 -05:00
parent f9e5dacda8
commit 278690e094
8 changed files with 462 additions and 275 deletions

View File

@@ -1,4 +1,6 @@
import { BatchPromotion } from '@shared/schemas/promotionSchema';
import { Rank } from '@shared/types/rank'
// @ts-ignore
const addr = import.meta.env.VITE_APIHOST;
@@ -15,19 +17,19 @@ export async function getAllRanks(): Promise<Rank[]> {
}
// Placeholder: submit a rank change
export async function submitRankChange(member_id: number, rank_id: number, date: string): Promise<{ ok: boolean }> {
export async function submitRankChange(promo: BatchPromotion) {
const res = await fetch(`${addr}/memberRanks`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ change: { member_id, rank_id, date } }),
credentials: 'include',
body: JSON.stringify(promo),
})
if (res.ok) {
return { ok: true }
return
} else {
console.error("Failed to submit rank change")
return { ok: false }
throw new Error("Failed to submit rank change: Server error");
}
}