Began implementation for getting promotion history
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user