Archived
- Internal links use next/link instead of <a> (no full page reload). - Remove dead code: RegisterForm's unreachable Yoco checkout branch, the unused AttendeeForms on the registration success page, unused Geist fonts, and assorted unused variables and catch bindings. - Escape quotes in JSX text; replace @ts-ignore in apiFetch with a cast. - Keep the intentional raw <img> elements (data URLs, runtime API host) with a documented lint exception; the event editor uses ApiImage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import React from "react";
|
|
import QRCode from "qrcode";
|
|
|
|
type Props = {
|
|
value: string;
|
|
size?: number;
|
|
alt?: string;
|
|
className?: string;
|
|
};
|
|
|
|
/**
|
|
* On-screen QR preview generated locally (via the `qrcode` package) instead of hitting
|
|
* api.qrserver.com — removes a third-party network dependency from ticket views that are
|
|
* viewed frequently (dashboard, event-tickets, at-the-door).
|
|
*/
|
|
export function QrImage({ value, size = 120, alt = "QR", className }: Props) {
|
|
const [dataUrl, setDataUrl] = React.useState<string | null>(null);
|
|
|
|
React.useEffect(() => {
|
|
let cancelled = false;
|
|
QRCode.toDataURL(value, { width: size, margin: 1 })
|
|
.then((url) => { if (!cancelled) setDataUrl(url); })
|
|
.catch(() => { if (!cancelled) setDataUrl(null); });
|
|
return () => { cancelled = true; };
|
|
}, [value, size]);
|
|
|
|
if (!dataUrl) return <div className={`${className || ""} bg-gray-100 animate-pulse`} aria-hidden="true" />;
|
|
// A data: URL generated in the browser — nothing for next/image to optimize.
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
return <img src={dataUrl} alt={alt} className={className} />;
|
|
}
|