Archived
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:
@@ -300,8 +300,6 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
|
||||
return initial;
|
||||
});
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [registrationId, setRegistrationId] = useState<string | null>(null);
|
||||
const [creatingCheckout, setCreatingCheckout] = useState(false);
|
||||
const [creatingRegistration, setCreatingRegistration] = useState(false);
|
||||
const [coupon, setCoupon] = useState<AppliedCoupon | null>(null);
|
||||
const [namingOthers, setNamingOthers] = useState(false);
|
||||
@@ -484,27 +482,6 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
|
||||
}
|
||||
};
|
||||
|
||||
const createYocoCheckout = async () => {
|
||||
if (!token || !registrationId) return;
|
||||
try {
|
||||
setCreatingCheckout(true);
|
||||
const res = await apiFetch<{ redirectUrl: string }>("/api/payments/yoco-checkout", {
|
||||
method: "POST",
|
||||
body: {
|
||||
registrationId,
|
||||
successUrl: window.location.origin + "/payment/success",
|
||||
cancelUrl: window.location.origin + "/payment/cancel",
|
||||
failureUrl: window.location.origin + "/payment/failure",
|
||||
},
|
||||
authToken: token,
|
||||
});
|
||||
window.open(res.redirectUrl, "_blank");
|
||||
} catch (e: any) {
|
||||
setError(e?.message || "Failed to create checkout");
|
||||
} finally {
|
||||
setCreatingCheckout(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -628,12 +605,11 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
|
||||
)}
|
||||
<div className="text-lg font-semibold">Total: R{payable.toFixed(2)}</div>
|
||||
</div>
|
||||
{!registrationId ? (
|
||||
eventSoldOut ? (
|
||||
<button disabled className="bg-red-50 text-red-700 border border-red-200 px-4 py-2 rounded cursor-not-allowed">
|
||||
Sold Out
|
||||
</button>
|
||||
) : (
|
||||
{eventSoldOut ? (
|
||||
<button disabled className="bg-red-50 text-red-700 border border-red-200 px-4 py-2 rounded cursor-not-allowed">
|
||||
Sold Out
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={submitRegistration}
|
||||
disabled={creatingRegistration || (!isLoggedIn && !isGuestEligible && !waitlistToken)}
|
||||
@@ -641,15 +617,6 @@ export default function RegisterForm({ event: baseEvent }: { event: Event }) {
|
||||
>
|
||||
{creatingRegistration ? "Registering..." : "Register"}
|
||||
</button>
|
||||
)
|
||||
) : (
|
||||
<button
|
||||
onClick={createYocoCheckout}
|
||||
disabled={creatingCheckout}
|
||||
className="bg-green-600 text-white px-4 py-2 rounded disabled:opacity-60"
|
||||
>
|
||||
{creatingCheckout ? "Creating checkout..." : "Pay with Yoco"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user