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:
@@ -318,7 +318,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
const byEv: Record<string, Payment[]> = {};
|
||||
for (const id of eventIds) {
|
||||
try {
|
||||
const list = await apiFetch<Payment[]>(`/api/payments/event/${encodeURIComponent(id)}`, { authToken: token });
|
||||
const list = await (apiV2Data("get", "/events/{id}/payments", { params: { id: id }, authToken: token }) as Promise<Payment[]>);
|
||||
byEv[id] = Array.isArray(list) ? list : [];
|
||||
} catch {
|
||||
byEv[id] = [];
|
||||
@@ -360,7 +360,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
const byEv: Record<string, EventFinancials | null> = {};
|
||||
for (const id of eventIds) {
|
||||
try {
|
||||
byEv[id] = await apiFetch<EventFinancials>(`/api/cashups/event/${encodeURIComponent(id)}`, { authToken: token });
|
||||
byEv[id] = await (apiV2Data("get", "/events/{id}/cashup", { params: { id: id }, authToken: token }) as Promise<EventFinancials>);
|
||||
} catch {
|
||||
byEv[id] = null;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
const loadFeedback = async (eventIds: string[]) => {
|
||||
if (!token || !eventIds.length) return [];
|
||||
try {
|
||||
return await apiFetch<FeedbackEventSummary[]>(`/api/feedback/summary?eventIds=${encodeURIComponent(eventIds.join(","))}`, { authToken: token });
|
||||
return await (apiV2Data("get", "/feedback/summary", { query: { eventIds: eventIds.join(",") }, authToken: token }) as Promise<FeedbackEventSummary[]>);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
@@ -412,7 +412,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
const ev = filteredEvents.find((e) => e.id === id);
|
||||
if (!ev?.requiresParentalConsent) continue;
|
||||
try {
|
||||
const res = await apiFetch<{ rows?: (ConsentRow | MedicalRow)[] }>(`/api/consent/events/${encodeURIComponent(id)}${kind === "medical" ? "/medical" : ""}`, { authToken: token });
|
||||
const res = await ((kind === "medical" ? apiV2Data("get", "/events/{id}/consent/medical", { params: { id }, authToken: token }) : apiV2Data("get", "/events/{id}/consent", { params: { id }, authToken: token })) as Promise<{ rows?: (ConsentRow | MedicalRow)[] }>);
|
||||
(res?.rows || []).forEach((r) => out.push({ ...r, eventTitle: ev.title }));
|
||||
} catch { /* not allowed or not found — skip */ }
|
||||
}
|
||||
@@ -426,7 +426,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
if (auditTo) query.set("to", auditTo);
|
||||
if (eventIds.length === 1) query.set("eventId", eventIds[0]);
|
||||
try {
|
||||
const rows = await apiFetch<AuditRow[]>(`/api/cashups/audit?${query.toString()}`, { authToken: token });
|
||||
const rows = await (apiV2Data("get", "/cashups/audit", { query: Object.fromEntries(query), authToken: token }) as Promise<AuditRow[]>);
|
||||
const idSet = new Set(eventIds);
|
||||
const filtered = eventIds.length > 1 ? (rows || []).filter(r => idSet.has(r.eventId)) : (rows || []);
|
||||
return computeAuditDeltas(filtered).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
||||
|
||||
Reference in New Issue
Block a user