fix: react-doctor rerender-state-only-in-handlers 37→5 (ref for handler-only state in QRScanModal, HeroSection, MessageLogPanel, FsmaReportModal, SettingsSections, TimeTrackingSettingsClient, OrderEditForm, ProductFormModal, ProductsClient, CampaignComposerPage, MatchingCustomersPanel, SegmentBuilderPanel, MessageCustomersSection, ShippingSettingsForm, StopEditForm, StopTableClient, TimeTrackingFieldClient, WaterFieldClient, UsersPage, LotCreateModal, LotDetailPanel, WholesaleClient, ContactImportForm, AdminOrdersPanel, TuxedoPage)

This commit is contained in:
Nora
2026-06-26 07:10:42 -06:00
parent ce2dc8f070
commit ad0a0fe4ec
20 changed files with 161 additions and 181 deletions
+4 -4
View File
@@ -124,7 +124,7 @@ export default function UsersPage({ initialUsers, brands, currentUser, onUserCre
const [deleteConfirmId, setDeleteConfirmId] = useState<string | null>(null);
const [actionMenuId, setActionMenuId] = useState<string | null>(null);
const [passwordModal, setPasswordModal] = useState<PasswordModal | null>(null);
const [resetLinkLoading, setResetLinkLoading] = useState<string | null>(null);
const resetLinkLoadingRef = useRef<string | null>(null);
const [success, setSuccess] = useState<string | null>(null);
// Auto-dismiss the success banner after 6 seconds.
@@ -327,17 +327,17 @@ export default function UsersPage({ initialUsers, brands, currentUser, onUserCre
}
async function handleSendResetLink(email: string) {
setResetLinkLoading(email);
resetLinkLoadingRef.current = email;
setError(null);
setSuccess(null);
try {
const { sendPasswordResetEmail } = await import("@/actions/admin/users");
const result = await sendPasswordResetEmail(email);
setResetLinkLoading(null);
resetLinkLoadingRef.current = null;
if (result.error) throw new Error(result.error);
setSuccess(`Password-reset email sent to ${email}.`);
} catch (e: unknown) {
setResetLinkLoading(null);
resetLinkLoadingRef.current = null;
setError(e instanceof Error ? e.message : "Failed to send reset email");
}
}