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:
@@ -2,11 +2,12 @@
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Award, Download } from "lucide-react";
|
||||
import { apiFetch, API_BASE } from "@/lib/api";
|
||||
import { API_BASE } from "@/lib/api";
|
||||
import { fetchApiFile, saveBlob } from "@/lib/export";
|
||||
import { formatDate } from "@/lib/date";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import type { MyCertificate } from "@/types";
|
||||
import { apiV2Data } from "@/lib/apiV2";
|
||||
|
||||
// Completion certificates on My Events. Hidden until the person has one.
|
||||
export function MyCertificates({ token }: { token: string | null }) {
|
||||
@@ -15,7 +16,7 @@ export function MyCertificates({ token }: { token: string | null }) {
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) return;
|
||||
apiFetch<MyCertificate[]>("/api/attendance/certificates/mine", { authToken: token })
|
||||
(apiV2Data("get", "/me/certificates", { authToken: token }) as Promise<MyCertificate[]>)
|
||||
.then(list => setCerts(Array.isArray(list) ? list : []))
|
||||
.catch(() => setCerts([]));
|
||||
}, [token]);
|
||||
@@ -26,7 +27,7 @@ export function MyCertificates({ token }: { token: string | null }) {
|
||||
if (!token) return;
|
||||
setError(null);
|
||||
try {
|
||||
saveBlob(await fetchApiFile(API_BASE, token, `/api/attendance/certificates/${c.id}/pdf`), `Certificate - ${c.event.title.replace(/[^a-z0-9 -]/gi, "")}.pdf`);
|
||||
saveBlob(await fetchApiFile(API_BASE, token, `/api/v2/certificates/${c.id}/pdf`), `Certificate - ${c.event.title.replace(/[^a-z0-9 -]/gi, "")}.pdf`);
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Download failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user