Fix frontend lint: links, unused code, quotes, img elements

- 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>
This commit is contained in:
2026-10-21 11:10:00 +02:00
co-authored by Claude Opus 5.5
parent f2be3a8b45
commit 958a5a5950
33 changed files with 73 additions and 266 deletions
@@ -180,8 +180,6 @@ function EmailAttendeesPageInner() {
// Tabs: attendees (current), automations (coming soon), broadcasts
const [tab, setTab] = useState<'attendees'|'automations'|'broadcasts'|'scheduled'>('attendees');
const isAdmin = user?.role === "admin";
const [allEvents, setAllEvents] = useState<any[]>([]);
const [evIncludePast, setEvIncludePast] = useState(false);
@@ -221,7 +219,7 @@ function EmailAttendeesPageInner() {
.map((u: any) => ({ id: u.id, name: u.name || '', email: u.email || '', pref: u.notificationPreference || 'email' }))
.sort((a: any, b: any) => (a.name || '').localeCompare(b.name || '', undefined, { sensitivity: 'base' }));
setUsers(mapped);
} catch (e) {
} catch {
// ignore for now
} finally {
setLoadingUsers(false);
@@ -277,7 +275,7 @@ function EmailAttendeesPageInner() {
setLoadingScheduled(true);
const res = await apiFetch<{jobs: ScheduledJob[]}>(`/api/scheduled-emails?channel=email`, { authToken: token });
setScheduled(Array.isArray(res?.jobs) ? res.jobs : []);
} catch (e) {
} catch {
// ignore here; surfaces via UI when tab open
} finally {
setLoadingScheduled(false);
@@ -402,7 +400,7 @@ function EmailAttendeesPageInner() {
// Default: select those with email/both preference; fall back to all
const matching = list.filter(a => a.pref === 'email' || a.pref === 'both').map(a => a.id);
setSelectedAttendeeIds(matching.length > 0 ? matching : list.map(a => a.id));
} catch (e) {
} catch {
// ignore
} finally {
setLoadingAttendees(false);
@@ -584,7 +582,7 @@ function EmailAttendeesPageInner() {
<li><code>{'{{event.title}}'}</code> — the event title.</li>
<li><code>{'{{event.start}}'}</code> — the event start date/time (local).</li>
<li><code>{'{{balance}}'}</code> — outstanding amount across the attendee’s registrations for the selected event.</li>
<li><code>{'{{payment.link}}'}</code> — a direct Yoco payment link for the attendee's outstanding balance (generated per recipient when sending).</li>
<li><code>{'{{payment.link}}'}</code> — a direct Yoco payment link for the attendee&apos;s outstanding balance (generated per recipient when sending).</li>
</ul>
<p className="mb-2">Example: Hi <code>{'{{name}}'}</code>, your balance is <code>{'{{balance}}'}</code>. Pay here: <code>{'{{payment.link}}'}</code></p>
<p className="text-[11px] text-gray-500">To add new placeholders, extend <span className="font-mono">backend/src/utils/placeholders.js</span> and update this help.</p>
@@ -113,20 +113,16 @@ function EventOptionsContent() {
const [events, setEvents] = useState<any[]>([]);
const [selectedEventId, setSelectedEventId] = useState<string>("");
const [options, setOptions] = useState<any[]>([]);
const [loadingEv, setLoadingEv] = useState(false);
const [error, setError] = useDismissingState<string | null>(null);
const [info, setInfo] = useDismissingState<string | null>(null);
const loadEvents = async () => {
if (!token) return;
try {
setLoadingEv(true);
const evs = await apiFetch<any[]>("/api/events/all", { authToken: token });
setEvents(evs || []);
} catch (e) {
} catch {
// ignore
} finally {
setLoadingEv(false);
}
};
@@ -4,7 +4,8 @@ import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from "re
import { createPortal } from "react-dom";
import { useAuth } from "@/hooks/useAuth";
import { useRouter } from "next/navigation";
import { apiFetch, resolveToApiOrigin } from "@/lib/api";
import { apiFetch } from "@/lib/api";
import { ApiImage } from "@/components/shared/ApiImage";
import { useDismissingState } from "@/hooks/useDismissingState";
import { useSiteSettings } from "@/contexts/SiteSettingsContext";
import { Calendar } from "lucide-react";
@@ -819,8 +820,7 @@ interface EventModalProps {
}
function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) {
const { token, user } = useAuth();
const isAdmin = user?.role === "admin";
const { token } = useAuth();
const { settings } = useSiteSettings();
const [step, setStep] = useState<StepIdx>(0);
const [pricingSubstep, setPricingSubstep] = useState<PricingSubstep>(0);
@@ -1306,7 +1306,7 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) {
<div className="p-5 space-y-4 max-h-[65vh] overflow-y-auto">
{isClosed && (
<div className="p-3 border rounded bg-rose-50 text-rose-800 text-sm">
This event is closed — it can't be edited until it's reopened from the cashup page (admin only).
This event is closed — it can&apos;t be edited until it&apos;s reopened from the cashup page (admin only).
</div>
)}
{error && <div className="p-3 border rounded bg-red-50 text-red-700 text-sm">{error}</div>}
@@ -1342,7 +1342,7 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) {
onChange={e => upd({ requiresRegistration: !e.target.checked, price: e.target.checked ? "0" : draft.price })}
/>
<label htmlFor="contact-only-toggle" className="text-xs text-gray-700">
<span className="font-medium">This is a contact-only event</span> (e.g. baptism) — no online registration or payment. Shows a "Contact us" button on the public site instead of "Register".
<span className="font-medium">This is a contact-only event</span> (e.g. baptism) — no online registration or payment. Shows a &quot;Contact us&quot; button on the public site instead of &quot;Register&quot;.
</label>
</div>
{draft.requiresRegistration ? (
@@ -1369,7 +1369,7 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) {
)}
<div>
<label className="block text-xs text-gray-600 mb-1">Picture</label>
{draft.picture && <img src={resolveToApiOrigin(draft.picture) || undefined} alt="" className="h-20 w-20 object-cover rounded border mb-2" />}
<ApiImage src={draft.picture} className="h-20 w-20 object-cover rounded border mb-2" />
<div className="flex items-center gap-2">
<input className="flex-1 border rounded px-3 py-2 text-sm" placeholder="/uploads/... or https://" value={draft.picture} onChange={e => upd({ picture: e.target.value })} />
<UploadImageButton onUploaded={url => upd({ picture: url })} label="Upload" />
@@ -1405,7 +1405,7 @@ function EventModal({ mode, event: ev, onClose, onSuccess }: EventModalProps) {
{/* ── Step 2: Sections ── */}
{step === 2 && (
<div>
<p className="text-xs text-gray-500 mb-3">Group ticket options into named sections shown on the registration page (e.g. "Tickets", "Add-ons", "Accommodation").</p>
<p className="text-xs text-gray-500 mb-3">Group ticket options into named sections shown on the registration page (e.g. &quot;Tickets&quot;, &quot;Add-ons&quot;, &quot;Accommodation&quot;).</p>
{mode === "edit" && ev?.id
? <SectionsManager eventId={ev.id} />
: <SectionsDraftEditor sections={sectionDrafts} options={options} onChange={setSectionDrafts} />
@@ -261,7 +261,7 @@ export default function ManualRegistrationPage() {
});
active.sort((a, b) => new Date(a.startDate).getTime() - new Date(b.startDate).getTime());
setEvents(active);
} catch (e: any) {
} catch {
// ignore
}
})();
@@ -86,7 +86,7 @@ export default function SupervisorDashboardPage() {
setPaymentStats(data.paymentStats);
setRecentScans(Array.isArray(data.recentScans) ? data.recentScans : []);
setOverview(overviewData);
} catch (e) {
} catch {
// ignore
} finally {
hasLoadedOnce.current = true;
@@ -209,7 +209,7 @@ function PaymentsContent() {
// Sort by createdAt desc
const sorted = list.sort((a,b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
setRegistrations(sorted);
} catch (e) {
} catch {
// ignore
} finally {
setLoadingRegs(false);
@@ -226,7 +226,7 @@ function PaymentsContent() {
setLoadingUsers(true);
const users = await fetchAllUsers(token);
setAllUsers(users);
} catch (e) {
} catch {
// ignore; fallback to derived users from registrations
} finally {
setLoadingUsers(false);
@@ -417,7 +417,7 @@ function PaymentsContent() {
}
try {
setSubmitting(true);
const res = await apiFetch<any>("/api/payments", {
await apiFetch("/api/payments", {
method: "POST",
authToken: token,
body: {
@@ -462,7 +462,7 @@ function PaymentsContent() {
const res = await apiFetch<any>("/api/yoco-transactions/unreconciled", { authToken: token });
const items = Array.isArray(res?.data) ? res.data : (Array.isArray(res) ? res : []);
setYocoTxs(items);
} catch (e) {
} catch {
// ignore silently, shown on demand via error state if needed
} finally {
setYocoLoading(false);
@@ -753,7 +753,6 @@ function PaymentsContent() {
<RefundSection
payments={payments}
allUsers={allUsers}
usersList={usersList}
regsForUser={(uid:string)=> registrations.filter((r:any)=> String(r.user?.id||r.userId)===String(uid))}
regOutstanding={regOutstanding}
onDone={async()=>{ await Promise.all([loadPayments(), loadRegistrations()]); setInfo('Refund recorded'); }}
@@ -877,13 +876,12 @@ function PaymentsContent() {
type RefundSectionProps = {
payments: any[];
allUsers: any[];
usersList: { id: string; name: string }[];
regsForUser: (userId: string) => any[];
regOutstanding: Record<string, { totalDue: number; totalPaid: number; outstanding: number }>;
onDone: () => void | Promise<void>;
};
function RefundSection({ payments, allUsers, usersList, regsForUser, regOutstanding, onDone }: RefundSectionProps) {
function RefundSection({ payments, allUsers, regsForUser, regOutstanding, onDone }: RefundSectionProps) {
const { token } = useAuth();
const [userId, setUserId] = useState<string>("");
const [target, setTarget] = useState<'payment'|'registration'>('payment');
@@ -1003,7 +1001,7 @@ function RefundSection({ payments, allUsers, usersList, regsForUser, regOutstand
<option value="eft-refund">EFT refund</option>
<option value="voucher-refund">Voucher refund</option>
</select>
<div className="text-[10px] text-gray-500 mt-1">Mirrors the method being refunded — this is what nets against that method's total in reports.</div>
<div className="text-[10px] text-gray-500 mt-1">Mirrors the method being refunded — this is what nets against that method&apos;s total in reports.</div>
</div>
</div>
<label className="block text-xs text-gray-600 mt-2">Reason (optional)</label>
@@ -693,7 +693,7 @@ function WhatsAppAttendeesPageInner() {
<li><code>{"{{event.title}}"}</code> — the event title.</li>
<li><code>{"{{event.start}}"}</code> — the event start date/time.</li>
<li><code>{"{{balance}}"}</code> — outstanding balance for the event.</li>
<li><code>{"{{payment.link}}"}</code> — a direct Yoco payment link for the attendee's outstanding balance (generated per recipient when sending).</li>
<li><code>{"{{payment.link}}"}</code> — a direct Yoco payment link for the attendee&apos;s outstanding balance (generated per recipient when sending).</li>
</ul>
<p className="text-[11px] text-gray-500 mt-2">
Preference indicators: <span className="text-green-700 bg-green-50 px-1 rounded">WA</span> = WhatsApp only,{" "}