WIP 1.51.10: registration management on v2 (routes, frontend)

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:04:31 +02:00
co-authored by Claude Opus 5.5
parent 5a3bfa1100
commit 7eb6f99e97
23 changed files with 4198 additions and 108 deletions
@@ -2,7 +2,7 @@
import React, { useEffect, useMemo, useState } from "react";
import { useAuth } from "@/hooks/useAuth";
import { apiFetch, createFullPaymentCheckout, fetchEvent } from "@/lib/api";
import { apiV2 } from "@/lib/apiV2";
import { apiV2, apiV2Data } from "@/lib/apiV2";
import { useOnlinePayments } from "@/lib/onlinePayments";
import { useRouter } from "next/navigation";
import { formatDate } from "@/lib/date";
@@ -124,7 +124,7 @@ export default function UserDashboardPage() {
// waterfalling — this was previously fetched only after registrations + all
// their payments had already resolved.
const [myRegs, myTicks] = await Promise.all([
apiFetch<Registration[]>(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token }),
(apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise<Registration[]>),
apiFetch<TicketRecord[]>("/api/tickets/mytickets", { authToken: token }),
]);
setRegistrations(myRegs);
@@ -189,7 +189,7 @@ export default function UserDashboardPage() {
return;
}
// Load registration to get number of submitted responses
const regFull = await apiFetch<Registration>(`/api/registrations/${encodeURIComponent(r.id)}`, { authToken: token });
const regFull = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: r.id }, authToken: token }) as Promise<Registration>);
const submittedCount = (regFull?.formResponses || []).length;
// Required count equals the number of main tickets purchased
const requiredCount = (r.registrationOptions || [])
@@ -273,11 +273,11 @@ export default function UserDashboardPage() {
loadingSubtitle: "Please wait while we prepare your invoice.",
});
try {
const res = await apiFetch<{ message?: string }>(`/api/registrations/${encodeURIComponent(registrationId)}/send-invoice`, {
method: "POST",
const res = await (apiV2Data("post", "/registrations/{id}/invoice", {
params: { id: registrationId },
body: { channel },
authToken: token,
});
}) as Promise<{ message?: string }>);
setDialog({ open: true, loading: false, title: "Invoice sent", message: (res && res.message) || "Invoice sent." });
} catch (e) {
setDialog({ open: false, message: "", loading: false });
@@ -332,7 +332,7 @@ export default function UserDashboardPage() {
// Refresh this registration's billing so the displayed outstanding reflects the new price
try {
const now = new Date();
const r = await apiFetch<Registration>(`/api/registrations/${encodeURIComponent(registrationId)}`, { authToken: token });
const r = await (apiV2Data("get", "/registrations/{id}/full", { params: { id: registrationId }, authToken: token }) as Promise<Registration>);
const pays = await apiFetch<Payment[]>(`/api/payments/registration/${encodeURIComponent(registrationId)}`, { authToken: token });
const totalPaid = pays.reduce((s, p) => s + (p.amount || 0), 0);
const totalDue = (r.registrationOptions || []).reduce((sum, opt) => sum + registrationOptionUnitPrice(opt, null, now) * (opt.quantity || 0), 0);
@@ -409,12 +409,12 @@ export default function UserDashboardPage() {
setCodeBusy(true);
setCodeError(null);
try {
const res = await apiFetch<{ message?: string }>(`/api/registrations/${encodeURIComponent(activeRegId)}/coupon`, {
method: 'POST',
const res = await (apiV2Data("post", "/registrations/{id}/coupon", {
params: { id: activeRegId },
authToken: token,
body: { code: codeInput.trim() },
});
const myRegs = await apiFetch<Registration[]>(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token });
}) as Promise<{ message?: string }>);
const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise<Registration[]>);
setRegistrations(myRegs);
const updated = myRegs.find(r => r.id === activeRegId);
const pays = await apiFetch<Payment[]>(`/api/payments/registration/${encodeURIComponent(activeRegId)}`, { authToken: token });
@@ -440,7 +440,7 @@ export default function UserDashboardPage() {
const reloadAfterAttendees = async () => {
if (!token) return;
try {
const myRegs = await apiFetch<Registration[]>(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token });
const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise<Registration[]>);
setRegistrations(myRegs);
const myTicks = await apiFetch<TicketRecord[]>("/api/tickets/mytickets", { authToken: token });
setTickets(myTicks);
@@ -456,7 +456,7 @@ export default function UserDashboardPage() {
setCancelLoading(true);
try {
await apiV2("post", "/registrations/{id}/cancel", { params: { id: activeRegId }, authToken: token });
const myRegs = await apiFetch<Registration[]>(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token });
const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise<Registration[]>);
setRegistrations(myRegs);
setActiveRegId(null);
setShowCancelConfirm(false);
@@ -593,13 +593,13 @@ export default function UserDashboardPage() {
}
setLoading(true);
try {
await apiFetch(`/api/registrations/${encodeURIComponent(activeReg.id)}/options`, {
method: 'PUT',
await apiV2Data("put", "/registrations/{id}/items", {
params: { id: activeReg.id },
authToken: token,
body: { options: payloadOptions },
});
// Reload registrations to reflect changes
const myRegs = await apiFetch<Registration[]>(`/api/registrations/myregistrations?showPast=${showPast ? '1' : '0'}`, { authToken: token });
const myRegs = await (apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise<Registration[]>);
setRegistrations(myRegs);
try {
const myTicks = await apiFetch<TicketRecord[]>("/api/tickets/mytickets", { authToken: token });