diff --git a/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx b/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx index 69598a21..7da3a29e 100644 --- a/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx +++ b/apps/dokploy/components/dashboard/application/schedules/show-schedules.tsx @@ -39,18 +39,10 @@ export const ShowSchedules = ({ applicationId }: Props) => { const utils = api.useUtils(); const { mutateAsync: deleteSchedule, isLoading: isDeleting } = - api.schedule.delete.useMutation({ - onSuccess: () => { - utils.schedule.list.invalidate({ applicationId }); - }, - }); + api.schedule.delete.useMutation(); const { mutateAsync: runManually, isLoading } = - api.schedule.runManually.useMutation({ - onSuccess: () => { - utils.schedule.list.invalidate({ applicationId }); - }, - }); + api.schedule.runManually.useMutation(); return ( @@ -65,7 +57,9 @@ export const ShowSchedules = ({ applicationId }: Props) => { - + {schedules && schedules.length > 0 && ( + + )} @@ -138,8 +132,12 @@ export const ShowSchedules = ({ applicationId }: Props) => { toast.success( "Schedule run successfully", ); + utils.schedule.list.invalidate({ + applicationId, + }); }) .catch((error) => { + console.log(error); toast.error( error instanceof Error ? error.message @@ -201,11 +199,15 @@ export const ShowSchedules = ({ applicationId }: Props) => { ) : ( -
- -

- No scheduled tasks found +

+ +

+ No scheduled tasks

+

+ Create your first scheduled task to automate your workflows +

+
)} diff --git a/apps/dokploy/server/api/routers/schedule.ts b/apps/dokploy/server/api/routers/schedule.ts index aeb07f15..cdf3b90e 100644 --- a/apps/dokploy/server/api/routers/schedule.ts +++ b/apps/dokploy/server/api/routers/schedule.ts @@ -95,8 +95,16 @@ export const scheduleRouter = createTRPCRouter({ runManually: protectedProcedure .input(z.object({ scheduleId: z.string().min(1) })) .mutation(async ({ input }) => { - await runCommand(input.scheduleId); - - return true; + try { + await runCommand(input.scheduleId); + return true; + } catch (error) { + console.log(error); + throw new TRPCError({ + code: "INTERNAL_SERVER_ERROR", + message: + error instanceof Error ? error.message : "Error running schedule", + }); + } }), });