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:
@@ -4,6 +4,7 @@ import "server-only";
|
||||
import { getSession } from "@/lib/auth";
|
||||
import { setUserPassword } from "@/lib/auth";
|
||||
import { getAdminUser } from "@/lib/admin-permissions";
|
||||
import { serverLog, serverError } from "@/lib/server-log";
|
||||
|
||||
const MIN_PASSWORD_LENGTH = 8;
|
||||
|
||||
@@ -40,14 +41,14 @@ await getSession(); // Verify the caller is an admin
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
console.error("[updatePassword] Failed:", result.error);
|
||||
serverError("[updatePassword] Failed:", result.error);
|
||||
return { success: false, error: result.error.message ?? "Failed to update password." };
|
||||
}
|
||||
|
||||
console.log("[updatePassword] Password updated for user:", userId);
|
||||
serverLog("[updatePassword] Password updated for user:", userId);
|
||||
return { success: true };
|
||||
} catch (err) {
|
||||
console.error("[updatePassword] Unexpected error:", err);
|
||||
serverError("[updatePassword] Unexpected error:", err);
|
||||
return { success: false, error: "An unexpected error occurred." };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import "server-only";
|
||||
import { randomBytes } from "crypto";
|
||||
import { query } from "@/lib/db";
|
||||
import { serverWarn } from "@/lib/server-log";
|
||||
import {
|
||||
requestPasswordReset as neonAuthRequestPasswordReset,
|
||||
setUserPassword as neonAuthSetUserPassword,
|
||||
@@ -84,7 +85,7 @@ await getSession(); // 1. Authz check.
|
||||
code === "FORBIDDEN" ||
|
||||
code === "UNAUTHORIZED" ||
|
||||
code === "INTERNAL_SERVER_ERROR";
|
||||
console.warn(
|
||||
serverWarn(
|
||||
"[resetAdminPassword] setUserPassword failed (code=%s), will%s fall back: %s",
|
||||
code,
|
||||
canFallback ? "" : " NOT",
|
||||
@@ -107,7 +108,7 @@ await getSession(); // 1. Authz check.
|
||||
[user.id],
|
||||
);
|
||||
} catch (flagErr) {
|
||||
console.warn(
|
||||
serverWarn(
|
||||
"[resetAdminPassword] failed to set must_change_password (non-fatal):",
|
||||
flagErr,
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import "server-only";
|
||||
import { query, withTx } from "@/lib/db";
|
||||
import { serverWarn } from "@/lib/server-log";
|
||||
import {
|
||||
createUser as neonAuthCreateUser,
|
||||
requestPasswordReset as neonAuthRequestPasswordReset,
|
||||
@@ -131,7 +132,7 @@ async function sendWelcomeEmailSafe(input: {
|
||||
brandName = settings.settings.brand_name ?? brandName;
|
||||
}
|
||||
} catch (brandErr) {
|
||||
console.warn(
|
||||
serverWarn(
|
||||
"[createAdminUser] Failed to load brand settings for welcome email:",
|
||||
brandErr,
|
||||
);
|
||||
@@ -495,7 +496,7 @@ async function signupFallbackCreate(
|
||||
try {
|
||||
await query(`UPDATE neon_auth.user SET "emailVerified" = true WHERE id = $1`, [userId]);
|
||||
} catch (verifyErr) {
|
||||
console.warn(
|
||||
serverWarn(
|
||||
"[createAdminUser] Failed to set emailVerified=true (non-fatal):",
|
||||
verifyErr,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user