diff --git a/apps/dokploy/components/dashboard/application/schedules/show-schedules-logs.tsx b/apps/dokploy/components/dashboard/application/schedules/show-schedules-logs.tsx index afa08dff1..aabc8e11f 100644 --- a/apps/dokploy/components/dashboard/application/schedules/show-schedules-logs.tsx +++ b/apps/dokploy/components/dashboard/application/schedules/show-schedules-logs.tsx @@ -13,17 +13,18 @@ import { import type { RouterOutputs } from "@/utils/api"; import { useState } from "react"; import { ShowDeployment } from "../deployments/show-deployment"; +import { ClipboardList } from "lucide-react"; interface Props { deployments: RouterOutputs["deployment"]["all"]; serverId?: string; - trigger?: React.ReactNode; + children?: React.ReactNode; } export const ShowSchedulesLogs = ({ deployments, serverId, - trigger, + children, }: Props) => { const [activeLog, setActiveLog] = useState< RouterOutputs["deployment"]["all"][number] | null @@ -32,8 +33,8 @@ export const ShowSchedulesLogs = ({ return ( - {trigger ? ( - trigger + {children ? ( + children ) : ( + + - - ))} - + ))} + + ) : ( +
+ +

No logs found

+

This schedule hasn't been executed yet

+
+ )} { const { data: schedules } = api.schedule.list.useQuery({ applicationId, }); + const utils = api.useUtils(); - const { mutate: deleteSchedule } = api.schedule.delete.useMutation({ - onSuccess: () => { - utils.schedule.list.invalidate({ applicationId }); - }, - }); + const { mutateAsync: deleteSchedule, isLoading: isDeleting } = + api.schedule.delete.useMutation({ + onSuccess: () => { + utils.schedule.list.invalidate({ applicationId }); + }, + }); - const { mutateAsync: runManually } = api.schedule.runManually.useMutation({ - onSuccess: () => { - utils.schedule.list.invalidate({ applicationId }); - }, - }); - - const utils = api.useContext(); + const { mutateAsync: runManually, isLoading } = + api.schedule.runManually.useMutation({ + onSuccess: () => { + utils.schedule.list.invalidate({ applicationId }); + }, + }); return ( @@ -114,27 +121,40 @@ export const ShowSchedules = ({ applicationId }: Props) => { deployments={deployments || []} serverId={application.serverId || undefined} /> - + + + + + + + + Run Manual Schedule + + + { variant="ghost" size="sm" className="text-destructive hover:text-destructive" - onClick={() => - deleteSchedule({ + isLoading={isDeleting} + onClick={async () => { + await deleteSchedule({ scheduleId: schedule.scheduleId, }) - } + .then(() => { + toast.success( + "Schedule deleted successfully", + ); + }) + .catch((error) => { + toast.error( + error instanceof Error + ? error.message + : "Error deleting schedule", + ); + }); + }} > Delete