Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat(web): add delete api key mutation hook

Andrej Acevskiaf4f4a5dc29c
diff --git a/apps/web/src/hooks/mutations/api-key/use-delete-api-key.ts b/apps/web/src/hooks/mutations/api-key/use-delete-api-key.ts
new file mode 100644
index 000000000..6be830ea8
--- /dev/null
+++ b/apps/web/src/hooks/mutations/api-key/use-delete-api-key.ts
@@ -0,0 +1,25 @@
+import { useMutation, useQueryClient } from "@tanstack/react-query";
+import { authClient } from "@/lib/auth-client";
+
+function useDeleteApiKey() {
+ const queryClient = useQueryClient();
+
+ return useMutation({
+ mutationFn: async (keyId: string) => {
+ const result = await authClient.apiKey.delete({
+ keyId: keyId,
+ });
+
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+
+ return result.data;
+ },
+ onSuccess: () => {
+ queryClient.invalidateQueries({ queryKey: ["api-keys"] });
+ },
+ });
+}
+
+export default useDeleteApiKey;