WIP 2.0.0: React Compiler lint rules back to errors; docs
- The 192 places the rules flagged are fixed and the rules are errors again (npx eslint src: nothing). lib/hooks.ts: useStateSync (state that follows other state, set while rendering), useExternalEffect (API loads and browser reads), useNow; lib/navigation.ts hardNavigate for full reloads after sign-out or identity switches; other pages use the router. Resets moved into the handlers that cause them. - The banner shows and hides at its times on open pages. - HANDOVER, roadmap, README, FEATURES, SETTINGS, CHANGELOG updated; 2.0.0 section drafted in WHATS-NEW. e2e 102/102 (PayFast sandbox skipped); production build passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import { ModalOverlay } from "@/components/shared/ModalOverlay";
|
||||
import { EventPicker } from "@/components/shared/EventPicker";
|
||||
import { apiV2Data, apiV2 } from "@/lib/apiV2";
|
||||
import { toAuthResponse } from "@/contexts/AuthContext";
|
||||
import { useExternalEffect, useStateSync } from "@/lib/hooks";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
type EarlyBirdTier = { deadline: string; price: number; order?: number; variantId?: string | null };
|
||||
@@ -220,7 +221,7 @@ export default function SelfServicePage() {
|
||||
// The events list doesn't carry bundle deals or places per session; the single-event
|
||||
// response does.
|
||||
const [kioskFull, setKioskFull] = useState<Event | null>(null);
|
||||
useEffect(() => {
|
||||
useExternalEffect(() => {
|
||||
if (!selectedEventId) { setKioskBundles([]); setKioskFull(null); return; }
|
||||
let cancelled = false;
|
||||
fetchEvent<Event>(selectedEventId, { authToken: supervisorToken || undefined })
|
||||
@@ -231,7 +232,6 @@ export default function SelfServicePage() {
|
||||
|
||||
// "Pick sessions" options: the sessions chosen per quantity key.
|
||||
const [picks, setPicks] = useState<Record<string, string[]>>({});
|
||||
useEffect(() => { setPicks({}); }, [selectedEventId]);
|
||||
const pickOpt = (optionId: string) => {
|
||||
const o = (kioskFull?.eventOptions || []).find(x => x.id === optionId);
|
||||
return kioskFull && o && isPickOption(kioskFull, o) ? o : null;
|
||||
@@ -417,6 +417,7 @@ export default function SelfServicePage() {
|
||||
setShowChangeModal(false);
|
||||
setScreen("setup");
|
||||
setSelectedEventId("");
|
||||
setPicks({});
|
||||
resetForm();
|
||||
} catch (err) {
|
||||
setChangeError(errorMessage(err) || "Incorrect password.");
|
||||
@@ -613,7 +614,6 @@ export default function SelfServicePage() {
|
||||
setShowVisitorPassword(false);
|
||||
setEmailMatch(null);
|
||||
setPhoneMatch(null);
|
||||
appliedMatchIdRef.current = null;
|
||||
setShowUpdateConfirm(false);
|
||||
setLookupMessage(null);
|
||||
setFormError(null);
|
||||
@@ -683,18 +683,19 @@ export default function SelfServicePage() {
|
||||
// object identity instead of id made it re-fire and stomp every field — including
|
||||
// ones the operator had already deliberately edited — back to the account's
|
||||
// original values on every unrelated tap.
|
||||
const appliedMatchIdRef = useRef<string | null>(null);
|
||||
useEffect(() => {
|
||||
if (!matchedAccount || appliedMatchIdRef.current === matchedAccount.id) return;
|
||||
appliedMatchIdRef.current = matchedAccount.id;
|
||||
// Fill the form in once per matched account (not again when the same account comes back as a
|
||||
// new object, which would undo what the visitor typed). Starting over clears the match.
|
||||
useStateSync(() => {
|
||||
if (!matchedAccount) return;
|
||||
setVisitorName(matchedAccount.name);
|
||||
if (matchedAccount.email) setVisitorEmail(matchedAccount.email);
|
||||
if (matchedAccount.phoneNumber) setVisitorPhone(matchedAccount.phoneNumber);
|
||||
setNotificationPref(matchedAccount.notificationPreference);
|
||||
}, [matchedAccount]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [matchedAccount?.id]);
|
||||
|
||||
// Existing accounts are linked automatically — never show the "create account" toggle for them
|
||||
useEffect(() => {
|
||||
useExternalEffect(() => {
|
||||
if (accountExists && createAccount) {
|
||||
setCreateAccount(false);
|
||||
setVisitorPassword("");
|
||||
@@ -854,7 +855,7 @@ export default function SelfServicePage() {
|
||||
) : (
|
||||
<div>
|
||||
<label htmlFor="kiosk-event" className="block text-sm font-medium text-gray-700 mb-1">Event</label>
|
||||
<EventPicker id="kiosk-event" className="w-full text-base" events={events} value={selectedEventId} onChange={setSelectedEventId} placeholder="Select an event" />
|
||||
<EventPicker id="kiosk-event" className="w-full text-base" events={events} value={selectedEventId} onChange={id => { setSelectedEventId(id); setPicks({}); }} placeholder="Select an event" />
|
||||
</div>
|
||||
)}
|
||||
{selectedEvent && (
|
||||
|
||||
Reference in New Issue
Block a user