WIP 1.51.11: money on v2 via v1 handlers (viaV1 adapter)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -248,8 +248,15 @@ export function fetchAllUsers(token: string, params: Record<string, string> = {}
|
||||
return fetchAllPages<User>("/api/users", token, params);
|
||||
}
|
||||
|
||||
export function fetchAllPayments(token: string, params: Record<string, string> = {}): Promise<Payment[]> {
|
||||
return fetchAllPages<Payment>("/api/payments", token, params);
|
||||
/** Every payment staff may see (API v2 GET /payments, all pages at once). */
|
||||
export async function fetchAllPayments(token: string, params: Record<string, string> = {}): Promise<Payment[]> {
|
||||
const { apiV2Data } = await import("@/lib/apiV2");
|
||||
const page = (n: number) => apiV2Data("get", "/payments", { query: { ...params, limit: "200", page: String(n) }, authToken: token }) as Promise<Paginated<Payment>>;
|
||||
const first = await page(1);
|
||||
const items: Payment[] = Array.isArray(first?.data) ? [...first.data] : [];
|
||||
const rest = await Promise.all(Array.from({ length: Math.max(0, (first?.pages || 1) - 1) }, (_, i) => page(i + 2)));
|
||||
for (const res of rest) if (Array.isArray(res?.data)) items.push(...res.data);
|
||||
return items;
|
||||
}
|
||||
|
||||
// Starts an online payment for everything still owed on one of my registrations (API v2), with
|
||||
|
||||
Reference in New Issue
Block a user