add server removal option

This commit is contained in:
ppc
2024-08-10 15:15:17 +01:00
parent 57884b31d5
commit f7e7236f59
+39 -1
View File
@@ -9,6 +9,17 @@ import {getServerInfo, serverCardIn} from "@/lib/aime-net";
import {Button} from "@/components/ui/button";
import {useToast} from "@/components/ui/use-toast";
import {Alert, AlertDescription, AlertTitle} from "@/components/ui/alert";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger
} from "@/components/ui/alert-dialog.tsx";
import {AMHeader} from "@/components/am-header.tsx";
import {AMFooter} from "@/components/am-footer.tsx";
@@ -17,6 +28,7 @@ import {LoadingIndicator} from "@/components/loading-indicator";
import {CardCreationDialog} from "@/components/card-creation-form";
import {NoCardsNotification} from "@/components/no-cards-notification";
/* eslint-disable @typescript-eslint/no-explicit-any */
async function performCardInAction(card: AimeCard, server: AimeServer, setCardInStatus: (status: boolean) => void, toaster: any) {
setCardInStatus(true);
@@ -171,7 +183,33 @@ function ServerCardInPage() {
}}/>
</div>
)}
<AMFooter/>
<AMFooter className="flex flex-col sm:flex-row justify-center sm:justify-between gap-2 flex-wrap">
{server?.id && (
<AlertDialog>
<AlertDialogTrigger>
<p className="text-sm text-red-700">Delete {server.name}</p>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Confirm Deletion</AlertDialogTitle>
<AlertDialogDescription>
You'll need to re-enter the server information if you want to use it in the future...
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={async () => {
await db.servers.delete(server.id);
navigate('/');
}}>
Continue
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
</AMFooter>
</main>
</>
);