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,19 +162,15 @@ export const ShowSchedules = ({ id, scheduleType = "application" }: Props) => {
size="icon" size="icon"
isLoading={isLoading} isLoading={isLoading}
onClick={async () => { onClick={async () => {
await runManually({
scheduleId: schedule.scheduleId,
})
.then(async () => {
toast.success("Schedule run successfully"); toast.success("Schedule run successfully");
await runManually({
scheduleId: schedule.scheduleId,
}).then(async () => {
await new Promise((resolve) => await new Promise((resolve) =>
setTimeout(resolve, 1500), setTimeout(resolve, 1500),
); );
refetchSchedules(); refetchSchedules();
})
.catch(() => {
toast.error("Error running schedule:");
}); });
}} }}
> >