blob: e2334c449b3d2d9a87bb178911c0ebc5a080022d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
"use client";
import { useRouter } from "next/navigation";
import { ActionButton } from "@/components/ui/action-button";
import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog";
import { Button } from "@/components/ui/button";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
import { Trash } from "lucide-react";
export default function DeleteApiKey({
name,
id,
}: {
name: string;
id: string;
}) {
const router = useRouter();
const mutator = api.apiKeys.revoke.useMutation({
onSuccess: () => {
toast({
description: "Key was successfully deleted",
});
router.refresh();
},
});
return (
<ActionConfirmingDialog
title={"Delete API Key"}
description={
<p>
Are you sure you want to delete the API key "{name}"? Any
service using this API key will lose access.
</p>
}
actionButton={(setDialogOpen) => (
<ActionButton
type="button"
variant="destructive"
loading={mutator.isPending}
onClick={() =>
mutator.mutate({ id }, { onSuccess: () => setDialogOpen(false) })
}
>
Delete
</ActionButton>
)}
>
<Button variant="outline">
<Trash size={18} color="red" />
</Button>
</ActionConfirmingDialog>
);
}
|