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 api key query hook

Andrej Acevskifbc07853c9a4
diff --git a/apps/web/src/hooks/queries/use-get-api-keys.ts b/apps/web/src/hooks/queries/use-get-api-keys.ts
new file mode 100644
index 000000000..befbb34fc
--- /dev/null
+++ b/apps/web/src/hooks/queries/use-get-api-keys.ts
@@ -0,0 +1,21 @@
+import { useQuery } from "@tanstack/react-query";
+import { authClient } from "@/lib/auth-client";
+import type { ApiKey } from "@/types/api-key";
+
+function useGetApiKeys() {
+ return useQuery({
+ queryKey: ["api-keys"],
+ queryFn: async () => {
+ const result = await authClient.apiKey.list();
+
+ if (result.error) {
+ throw new Error(result.error.message);
+ }
+
+ return (result.data || []) as ApiKey[];
+ },
+ });
+}
+
+export default useGetApiKeys;
+