From 43763853f890fe9245d3c12ff93d56a560172ba0 Mon Sep 17 00:00:00 2001 From: ajdj100 Date: Wed, 17 Dec 2025 16:02:20 -0500 Subject: [PATCH] Finished list render system --- ui/src/api/rank.ts | 72 +++++--- .../components/promotions/promotionList.vue | 167 ++++++++---------- .../promotions/promotionListDay.vue | 17 ++ ui/src/pages/RankChange.vue | 2 +- 4 files changed, 137 insertions(+), 121 deletions(-) create mode 100644 ui/src/components/promotions/promotionListDay.vue diff --git a/ui/src/api/rank.ts b/ui/src/api/rank.ts index 52f8631..d1e4eae 100644 --- a/ui/src/api/rank.ts +++ b/ui/src/api/rank.ts @@ -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 { - 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> { + 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 []; + } + }); } \ No newline at end of file diff --git a/ui/src/components/promotions/promotionList.vue b/ui/src/components/promotions/promotionList.vue index a8ccb77..f0d651f 100644 --- a/ui/src/components/promotions/promotionList.vue +++ b/ui/src/components/promotions/promotionList.vue @@ -1,6 +1,44 @@