"use client"; import React from "react"; import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { api } from "@/trpc/react"; import { toast } from "sonner"; import { useRouter } from "next/navigation"; function DeleteLobbyDialog({ lobbyId }: { lobbyId: string }) { const [loading, setLoading] = React.useState(false); const { mutateAsync } = api.lobby.delete.useMutation(); const router = useRouter(); const handleConfirm = async () => { setLoading(true); const result = await mutateAsync({ lobbyId }); if (result) { router.push("/"); } else toast.error("Something went wrong"); setLoading(false); }; return ( Are you absolutely sure? This action cannot be undone. You will permanently delete this lobby! Cancel Delete Lobby ); } export default DeleteLobbyDialog;