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:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user