delete server

This commit is contained in:
karamvir
2023-08-10 23:35:21 -07:00
parent b7d841be14
commit 3e260e4464
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { ActionWithDialog } from "@components/util";
import { useRead, useWrite } from "@hooks";
import { Trash } from "lucide-react";
import { useNavigate } from "react-router-dom";
export const DeleteServer = ({ id }: { id: string }) => {
const nav = useNavigate();
const { data: d } = useRead("GetServer", { id });
const { mutateAsync, isLoading } = useWrite("DeleteServer");
if (!d) return null;
return (
<ActionWithDialog
name={d.name}
title="Delete Server"
intent="danger"
icon={<Trash className="h-4 w-4" />}
onClick={async () => {
await mutateAsync({ id });
nav("/");
}}
disabled={isLoading}
/>
);
};

View File

@@ -23,6 +23,7 @@ import { Types } from "@monitor/client";
import { ConfigLayout } from "@layouts/page";
import { Button } from "@ui/button";
import { ConfigAgain } from "@components/config/again";
import { DeleteServer } from "./actions";
export const ServerCard = ({ id }: { id: string }) => {
const servers = useRead("ListServers", {}).data;
@@ -145,6 +146,10 @@ export const ServerPage = () => {
<ResourceUpdates type="Server" id={id} />
<ServerStats />
<ServerConfig id={id} />
<div className="flex items-center justify-between w-full">
danger zone {"B^)"}
<DeleteServer id={id} />
</div>
</Resource>
);
};