Finished list render system

This commit is contained in:
2025-12-17 16:02:20 -05:00
parent 278690e094
commit 43763853f8
4 changed files with 137 additions and 121 deletions

View File

@@ -1,35 +1,61 @@
import { BatchPromotion } from '@shared/schemas/promotionSchema';
import { Rank } from '@shared/types/rank'
import { PagedData } from '@shared/types/pagination';
import { PromotionSummary, Rank } from '@shared/types/rank'
// @ts-ignore
const addr = import.meta.env.VITE_APIHOST;
export async function getAllRanks(): Promise<Rank[]> {
const res = await fetch(`${addr}/ranks`, {
credentials: 'include'
})
const res = await fetch(`${addr}/ranks`, {
credentials: 'include'
})
if (res.ok) {
return res.json()
} else {
console.error("Something went wrong approving the application")
}
if (res.ok) {
return res.json()
} else {
console.error("Something went wrong approving the application")
}
}
// Placeholder: submit a rank change
export async function submitRankChange(promo: BatchPromotion) {
const res = await fetch(`${addr}/memberRanks`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
credentials: 'include',
body: JSON.stringify(promo),
})
const res = await fetch(`${addr}/memberRanks`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
credentials: 'include',
body: JSON.stringify(promo),
})
if (res.ok) {
return
} else {
throw new Error("Failed to submit rank change: Server error");
}
if (res.ok) {
return
} else {
throw new Error("Failed to submit rank change: Server error");
}
}
export async function getPromoHistory(page?: number, pageSize?: number): Promise<PagedData<PromotionSummary>> {
const params = new URLSearchParams();
if (page !== undefined) {
params.set("page", page.toString());
}
if (pageSize !== undefined) {
params.set("pageSize", pageSize.toString());
}
return fetch(`${addr}/memberRanks?${params}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
},
credentials: 'include',
}).then((res) => {
if (res.ok) {
return res.json();
} else {
return [];
}
});
}