import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; import { toast } from "sonner"; interface Props { applicationId: string; } export const DeployApplication = ({ applicationId }: Props) => { const { data, refetch } = api.application.one.useQuery( { applicationId, }, { enabled: !!applicationId }, ); const { mutateAsync: markRunning } = api.application.markRunning.useMutation(); const { mutateAsync: deploy } = api.application.deploy.useMutation(); return ( Are you absolutely sure? This will deploy the application Cancel { await markRunning({ applicationId, }) .then(async () => { toast.success("Application Deploying...."); await refetch(); await deploy({ applicationId, }) .then(() => { toast.success("Application Deployed Succesfully"); }) .catch(() => { toast.error("Error to deploy Application"); }); await refetch(); }) .catch((e) => { toast.error(e.message || "Error to deploy Application"); }); }} > Confirm ); };