Archived
WIP 1.51.12: tickets, scan locks, attendance, allocations on v2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { apiFetch, createFullPaymentCheckout, fetchEvent } from "@/lib/api";
|
||||
import { createFullPaymentCheckout, fetchEvent } from "@/lib/api";
|
||||
import { apiV2, apiV2Data } from "@/lib/apiV2";
|
||||
import { useOnlinePayments } from "@/lib/onlinePayments";
|
||||
import { useRouter } from "next/navigation";
|
||||
@@ -125,7 +125,7 @@ export default function UserDashboardPage() {
|
||||
// their payments had already resolved.
|
||||
const [myRegs, myTicks] = await Promise.all([
|
||||
(apiV2Data("get", "/me/registrations/full", { query: { past: showPast ? "true" : "false" }, authToken: token }) as Promise<Registration[]>),
|
||||
apiFetch<TicketRecord[]>("/api/tickets/mytickets", { authToken: token }),
|
||||
(apiV2Data("get", "/me/tickets", { authToken: token }) as Promise<TicketRecord[]>),
|
||||
]);
|
||||
setRegistrations(myRegs);
|
||||
setTickets(myTicks);
|
||||
@@ -230,11 +230,10 @@ export default function UserDashboardPage() {
|
||||
// Open loading dialog immediately
|
||||
setDialog({ open: true, message: "Sending tickets…", loading: true });
|
||||
try {
|
||||
const res = await apiFetch<{ message?: string }>("/api/tickets/email", {
|
||||
method: "POST",
|
||||
const res = await (apiV2Data("post", "/me/tickets/email", {
|
||||
body: { ticketIds },
|
||||
authToken: token,
|
||||
});
|
||||
}) as Promise<{ message?: string }>);
|
||||
const msg = (res && res.message) ? res.message : `${ticketIds.length} ticket(s) emailed successfully.`;
|
||||
setDialog({ open: true, message: msg, loading: false });
|
||||
} catch (e) {
|
||||
@@ -250,11 +249,10 @@ export default function UserDashboardPage() {
|
||||
setInfo(null);
|
||||
setDialog({ open: true, message: "Sending to WhatsApp…", loading: true });
|
||||
try {
|
||||
const res = await apiFetch<{ message?: string }>("/api/tickets/email", {
|
||||
method: "POST",
|
||||
const res = await (apiV2Data("post", "/me/tickets/email", {
|
||||
body: { ticketIds, channel: "whatsapp" },
|
||||
authToken: token,
|
||||
});
|
||||
}) as Promise<{ message?: string }>);
|
||||
const msg = (res && res.message) ? res.message : `${ticketIds.length} ticket(s) sent to WhatsApp.`;
|
||||
setDialog({ open: true, message: msg, loading: false });
|
||||
} catch (e) {
|
||||
@@ -422,7 +420,7 @@ export default function UserDashboardPage() {
|
||||
const totalDue = updated?.totalDueComputed ?? 0;
|
||||
setBilling(prev => ({ ...prev, [activeRegId]: { totalDue, totalPaid, outstanding: Math.max(0, totalDue - totalPaid), payments: pays } }));
|
||||
try {
|
||||
const myTicks = await apiFetch<TicketRecord[]>("/api/tickets/mytickets", { authToken: token });
|
||||
const myTicks = await (apiV2Data("get", "/me/tickets", { authToken: token }) as Promise<TicketRecord[]>);
|
||||
setTickets(myTicks);
|
||||
} catch {}
|
||||
setCodeInput("");
|
||||
@@ -442,7 +440,7 @@ export default function UserDashboardPage() {
|
||||
try {
|
||||
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 });
|
||||
const myTicks = await (apiV2Data("get", "/me/tickets", { authToken: token }) as Promise<TicketRecord[]>);
|
||||
setTickets(myTicks);
|
||||
} catch {}
|
||||
};
|
||||
@@ -602,7 +600,7 @@ export default function UserDashboardPage() {
|
||||
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 });
|
||||
const myTicks = await (apiV2Data("get", "/me/tickets", { authToken: token }) as Promise<TicketRecord[]>);
|
||||
setTickets(myTicks);
|
||||
} catch {}
|
||||
// Recompute billing totals using the backend's tranche-aware totalDueComputed
|
||||
@@ -921,7 +919,7 @@ export default function UserDashboardPage() {
|
||||
<span>Waiting for {t.transferRequests?.[0]?.toName} to accept</span>
|
||||
<button className="underline" onClick={async () => {
|
||||
try {
|
||||
const r = await apiFetch<{ message?: string }>(`/api/tickets/${t.id}/transfer`, { method: "DELETE", authToken: token! });
|
||||
const r = await (apiV2Data("delete", "/tickets/{id}/transfer", { params: { id: t.id }, authToken: token }) as Promise<{ message?: string }>);
|
||||
setInfo(r?.message || "Transfer cancelled");
|
||||
reloadAfterAttendees();
|
||||
} catch (e) { setError(errorMessage(e) || "Couldn't cancel"); }
|
||||
|
||||
Reference in New Issue
Block a user