Refactor schedule run handling in ShowSchedules component

- Simplified the schedule run logic by directly displaying a success toast upon execution.
- Removed redundant error handling for schedule runs, streamlining the code for better readability and maintainability.
This commit is contained in:
Mauricio Siu 2025-05-04 21:06:34 -06:00
parent b84b4549a0
commit b9ac25ef42

View File

@ -162,20 +162,16 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => {
size="icon"
isLoading={isLoading}
onClick={async () => {
toast.success("Schedule run successfully");
await runManually({
scheduleId: schedule.scheduleId,
})
.then(async () => {
toast.success("Schedule run successfully");
await new Promise((resolve) =>
setTimeout(resolve, 1500),
);
refetchSchedules();
})
.catch(() => {
toast.error("Error running schedule:");
});
}).then(async () => {
await new Promise((resolve) =>
setTimeout(resolve, 1500),
);
refetchSchedules();
});
}}
>
<Play className="size-4 transition-colors" />