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:
2026-10-29 13:43:36 +02:00
co-authored by Claude Opus 5.5
parent a45417948d
commit 6ee1438e23
36 changed files with 10334 additions and 154 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -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
+2 -2
View File
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useState } from "react";
import { apiFetch } from "@/lib/api";
import { apiV2Data } from "@/lib/apiV2";
type ProvidersResponse = { providers: { id: string; label: string }[]; minimumAmount: number };
@@ -21,7 +21,7 @@ export type OnlinePayments = {
// One request per page load, shared by every component that asks.
let pending: Promise<ProvidersResponse | null> | null = null;
function load() {
if (!pending) pending = apiFetch<ProvidersResponse>("/api/payments/providers").catch(() => null);
if (!pending) pending = (apiV2Data("get", "/payments/providers") as Promise<ProvidersResponse>).catch(() => null);
return pending;
}