refactor: consolidate 3 identical Redux slices into one seleniumTaskSlice
This commit is contained in:
@@ -50,7 +50,7 @@ import { useAppDispatch, useAppSelector } from "@/redux/hooks";
|
||||
import {
|
||||
clearTaskStatus,
|
||||
setTaskStatus,
|
||||
} from "@/redux/slices/seleniumEligibilityBatchCheckTaskSlice";
|
||||
} from "@/redux/slices/seleniumTaskSlice";
|
||||
import { SeleniumTaskBanner } from "@/components/ui/selenium-task-banner";
|
||||
import { PatientStatusBadge } from "@/components/appointments/patient-status-badge";
|
||||
import { AppointmentProceduresDialog } from "@/components/appointment-procedures/appointment-procedures-dialog";
|
||||
@@ -117,7 +117,7 @@ export default function AppointmentsPage() {
|
||||
}>({ open: false });
|
||||
const dispatch = useAppDispatch();
|
||||
const batchTask = useAppSelector(
|
||||
(state) => state.seleniumEligibilityBatchCheckTask
|
||||
(state) => state.seleniumTasks.eligibilityBatchCheck
|
||||
);
|
||||
const [isCheckingAllElig, setIsCheckingAllElig] = useState(false);
|
||||
const [processedAppointmentIds, setProcessedAppointmentIds] = useState<
|
||||
@@ -743,6 +743,7 @@ export default function AppointmentsPage() {
|
||||
// Start: set redux task status (visible globally)
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
key: "eligibilityBatchCheck",
|
||||
status: "pending",
|
||||
message: `Checking eligibility for appointments on ${dateParam}...`,
|
||||
})
|
||||
@@ -771,6 +772,7 @@ export default function AppointmentsPage() {
|
||||
// global error
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
key: "eligibilityBatchCheck",
|
||||
status: "error",
|
||||
message: `Batch eligibility failed: ${errMsg}`,
|
||||
})
|
||||
@@ -849,6 +851,7 @@ export default function AppointmentsPage() {
|
||||
// global success status (summary)
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
key: "eligibilityBatchCheck",
|
||||
status: skippedCount > 0 ? "error" : "success",
|
||||
message: `Batch processed ${results.length} appointments — success: ${successCount}, warnings: ${warningCount}, skipped: ${skippedCount}.`,
|
||||
})
|
||||
@@ -864,6 +867,7 @@ export default function AppointmentsPage() {
|
||||
console.error("[check-all-eligibilities] error", err);
|
||||
dispatch(
|
||||
setTaskStatus({
|
||||
key: "eligibilityBatchCheck",
|
||||
status: "error",
|
||||
message: `Batch eligibility error: ${err?.message ?? String(err)}`,
|
||||
})
|
||||
@@ -912,7 +916,7 @@ export default function AppointmentsPage() {
|
||||
status={batchTask.status}
|
||||
message={batchTask.message}
|
||||
show={batchTask.show}
|
||||
onClear={() => dispatch(clearTaskStatus())}
|
||||
onClear={() => dispatch(clearTaskStatus("eligibilityBatchCheck"))}
|
||||
/>
|
||||
|
||||
<div className="container mx-auto">
|
||||
|
||||
Reference in New Issue
Block a user