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:
@@ -174,7 +174,7 @@ export default function TimeTrackingFieldClient({
|
||||
}) {
|
||||
const [lang, setLang] = useState<"en" | "es">(() => (getLangCookie() as "en" | "es") ?? "en");
|
||||
const [screen, setScreen] = useState<Screen>("pin");
|
||||
const [session, setSession] = useState<TimeTrackingSession | null>(null);
|
||||
const sessionRef = useRef<TimeTrackingSession | null>(null);
|
||||
const [tasks, setTasks] = useState<TimeTaskField[]>([]);
|
||||
const [openEntry, setOpenEntry] = useState<OpenEntry | null>(null);
|
||||
const [payPeriod, setPayPeriod] = useState<PayPeriodHours | null>(null);
|
||||
@@ -219,7 +219,7 @@ export default function TimeTrackingFieldClient({
|
||||
await loadPayPeriodRef.current();
|
||||
return;
|
||||
}
|
||||
setSession(stored);
|
||||
sessionRef.current = stored;
|
||||
const open = await getOpenClockIn(brandId);
|
||||
await loadPayPeriodRef.current();
|
||||
|
||||
@@ -277,7 +277,7 @@ export default function TimeTrackingFieldClient({
|
||||
setError(result.error ?? t.invalid_pin);
|
||||
return;
|
||||
}
|
||||
setSession(result.session!);
|
||||
sessionRef.current = result.session!;
|
||||
const [open, taskList] = await Promise.all([
|
||||
getOpenClockIn(brandId),
|
||||
getTimeTrackingTasksField(brandId),
|
||||
@@ -303,7 +303,7 @@ export default function TimeTrackingFieldClient({
|
||||
await fetch("/api/time-tracking/notify", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ brandId, workerId: session?.worker_id, workerName, dailyHours, weeklyHours }),
|
||||
body: JSON.stringify({ brandId, workerId: sessionRef.current?.worker_id, workerName, dailyHours, weeklyHours }),
|
||||
});
|
||||
} catch {
|
||||
// non-critical
|
||||
@@ -340,7 +340,7 @@ export default function TimeTrackingFieldClient({
|
||||
});
|
||||
await loadPayPeriod();
|
||||
if (payPeriod) {
|
||||
dispatchNotification(session?.name ?? taskName, payPeriod.daily_hours, payPeriod.weekly_hours);
|
||||
dispatchNotification(sessionRef.current?.name ?? taskName, payPeriod.daily_hours, payPeriod.weekly_hours);
|
||||
}
|
||||
setScreen("working");
|
||||
};
|
||||
@@ -357,14 +357,14 @@ export default function TimeTrackingFieldClient({
|
||||
setClockOutResult({ clock_out: result.clock_out!, total_minutes: result.total_minutes ?? 0 });
|
||||
await loadPayPeriod();
|
||||
if (payPeriod) {
|
||||
dispatchNotification(session?.name ?? openEntry?.task_name ?? "Worker", payPeriod.daily_hours, payPeriod.weekly_hours);
|
||||
dispatchNotification(sessionRef.current?.name ?? openEntry?.task_name ?? "Worker", payPeriod.daily_hours, payPeriod.weekly_hours);
|
||||
}
|
||||
setScreen("clocked_out");
|
||||
};
|
||||
|
||||
const handleLogout = async () => {
|
||||
await logoutTimeTracking();
|
||||
setSession(null);
|
||||
sessionRef.current = null;
|
||||
setOpenEntry(null);
|
||||
setPayPeriod(null);
|
||||
setClockOutResult(null);
|
||||
|
||||
Reference in New Issue
Block a user