Skip to content

Commit 35cab79

Browse files
committed
fix(webapp): toast on enable/disable failure in the schedules sheet
The activeToggleFetcher effect previously short-circuited on `!data?.ok` and never surfaced server-returned errors (the update and delete effects already handled this). Split into success/failure branches so an `{ ok: false, message }` envelope from the action triggers `toast.error` instead of silently re-enabling the button.
1 parent 939fc94 commit 35cab79

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.tasks.scheduled.$taskParam

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.tasks.scheduled.$taskParam/route.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ function ScheduleSheet({
565565
const detailFetcher = useTypedFetcher<typeof scheduleDetailLoader>();
566566
const editFetcher = useTypedFetcher<typeof scheduleEditLoader>();
567567
// Embedded enable/disable — stays in the sheet via `_format=json`.
568-
const activeToggleFetcher = useFetcher<{ ok: boolean; active?: boolean }>();
568+
const activeToggleFetcher = useFetcher<{ ok: boolean; active?: boolean; message?: string }>();
569569
// Embedded update submission — same idea.
570570
const updateFetcher = useFetcher<{ ok: boolean; message?: string }>();
571571
// Embedded delete submission — same idea.
@@ -598,14 +598,18 @@ function ScheduleSheet({
598598
if (mode === "edit" && editPath) editFetcher.load(editPath);
599599
}, [mode, editPath]);
600600

601-
// Reload inspector data so Enable/Disable label flips.
601+
// Reload inspector data so Enable/Disable label flips; toast on error.
602602
useEffect(() => {
603603
const data = activeToggleFetcher.data;
604-
if (activeToggleFetcher.state !== "idle" || !data?.ok || !detailPath) return;
604+
if (activeToggleFetcher.state !== "idle" || !data) return;
605605
if (handledToggleRef.current === data) return;
606606
handledToggleRef.current = data;
607-
detailFetcher.load(detailPath);
608-
}, [activeToggleFetcher.state, activeToggleFetcher.data, detailPath]);
607+
if (data.ok) {
608+
if (detailPath) detailFetcher.load(detailPath);
609+
} else if (data.message) {
610+
toast.error(data.message);
611+
}
612+
}, [activeToggleFetcher.state, activeToggleFetcher.data, detailPath, toast]);
609613

610614
// Toast + back to inspect + reload so the inspector reflects the update.
611615
useEffect(() => {

0 commit comments

Comments
 (0)