fix: react-doctor → 64/100 (Bugs 122, Perf 286, A11y 613, Maint 436)

- CartContext: lazy initializers replace mount-only useEffect
  hydration; remove 8 no-initialize-state warnings
- Toast/AdminSearchInput: React 19 useContext/use + drop
  forwardRef (3 no-react19-deprecated-apis)
- ProductFormModal: lazy initializers + useSyncExternalStore
  for mount; parent adds key=editingProduct.id
- InstallPrompt: useReducer for prompt state (no-cascading-set-state)
- QRScanModal: ref-based latest-callback pattern replaces
  useEffectEvent deps mistake
- OnboardingFlow: functional setState (rerender-functional-setstate)
- UsersPage/StopsCalendar/FeaturesAndStats: lazy initializers
  (rerender-lazy-state-init)
- FAQClientPage: server-side brand settings fetch via getBrandSettingsPublic
  in layout; remove supabase import
- LandingPageWrapper: href='#' → href='#top' (anchor-is-valid)
- TuxedoVideoHero: replace animate-bounce with ease-out-expo
  (no-inline-bounce-easing)
- ProductTableClient: useCallback for handleDeleted
  (jsx-no-new-function-as-prop)
- excel-parser: pre-compile delimiter regexes (js-hoist-regexp)
- water-log/settings: Promise.all for parallel DB calls
  (async-parallel)
- ToastNotification: extract toast store to separate file
  (only-export-components)
- WholesaleClient: inline <WholesaleIcon/> instead of hoisting to
  const (rendering-hoist-jsx)
This commit is contained in:
Nora
2026-06-26 02:41:56 -06:00
parent 8e011da521
commit 29d9d23a26
88 changed files with 1399 additions and 1015 deletions
+11 -11
View File
@@ -1,7 +1,7 @@
"use client";
import Image from "next/image";
import { useState, useEffect, Suspense, useMemo } from "react";
import { useState, useEffect, Suspense, useMemo, useEffectEvent } from "react";
import {
verifyWaterPin,
submitWaterEntry,
@@ -130,7 +130,8 @@ function WaterFieldInner() {
});
const [step, setStep] = useState<"loading" | "lang" | "role" | "pin" | "form">(() => {
if (typeof document === "undefined") return "loading";
return document.cookie.match(/wl_session=([^;]+)/) ? "form" : "lang";
const hasSession = document.cookie.match(/wl_session=([^;]+)/);
return hasSession ? "form" : "lang";
});
const [pin, setPin] = useState("");
const [irrigatorName, setIrrigatorName] = useState("");
@@ -155,17 +156,16 @@ function WaterFieldInner() {
const t = LABELS[lang];
// Restore headgates on first render if user is already logged in
// (wl_session cookie present). Done in an effect so the initial step
// state can be set synchronously and headgates load asynchronously.
// On mount, if wl_session cookie is present, load headgates so the
// form is populated by the time the user lands. The step itself is
// already set in the lazy initializer above.
useEffect(() => {
if (step === "form" && headgates.length === 0) {
loadHeadgates();
if (typeof document === "undefined") return;
const hasSession = document.cookie.match(/wl_session=([^;]+)/);
if (hasSession) {
void loadHeadgates();
}
// loadHeadgates depends on TUXEDO_BRAND_ID + setters which never change
// across the component's lifetime, so we keep the dep list focused on
// the state we actually gate the load on.
}, [step, headgates.length]);
}, []);
// QR-locked headgate: derive during render instead of syncing in an effect.
// When qrHeadgateToken matches a loaded headgate, override the user's