From 65f6e83f11c82b0ec762e11f3392a80e614ee69a Mon Sep 17 00:00:00 2001
From: Mohamed Bassem <me@mbassem.com>
Date: Sun, 1 Feb 2026 12:29:54 +0000
Subject: refactor: migrate trpc to the new react query integration mode
 (#2438)

* refactor: migrate trpc to the new react query integration mode

* more fixes

* more migrations

* upgrade trpc client
---
 apps/web/components/settings/RegenerateApiKey.tsx | 32 +++++++++++++----------
 1 file changed, 18 insertions(+), 14 deletions(-)

(limited to 'apps/web/components/settings/RegenerateApiKey.tsx')

diff --git a/apps/web/components/settings/RegenerateApiKey.tsx b/apps/web/components/settings/RegenerateApiKey.tsx
index f4914598..9ee0e216 100644
--- a/apps/web/components/settings/RegenerateApiKey.tsx
+++ b/apps/web/components/settings/RegenerateApiKey.tsx
@@ -16,7 +16,8 @@ import {
 } from "@/components/ui/dialog";
 import { toast } from "@/components/ui/sonner";
 import { useTranslation } from "@/lib/i18n/client";
-import { api } from "@/lib/trpc";
+import { useTRPC } from "@/lib/trpc";
+import { useMutation } from "@tanstack/react-query";
 import { RefreshCcw } from "lucide-react";
 
 import ApiKeySuccess from "./ApiKeySuccess";
@@ -28,25 +29,28 @@ export default function RegenerateApiKey({
   id: string;
   name: string;
 }) {
+  const api = useTRPC();
   const { t } = useTranslation();
   const router = useRouter();
 
   const [key, setKey] = useState<string | undefined>(undefined);
   const [dialogOpen, setDialogOpen] = useState<boolean>(false);
 
-  const mutator = api.apiKeys.regenerate.useMutation({
-    onSuccess: (resp) => {
-      setKey(resp.key);
-      router.refresh();
-    },
-    onError: () => {
-      toast({
-        description: t("common.something_went_wrong"),
-        variant: "destructive",
-      });
-      setDialogOpen(false);
-    },
-  });
+  const mutator = useMutation(
+    api.apiKeys.regenerate.mutationOptions({
+      onSuccess: (resp) => {
+        setKey(resp.key);
+        router.refresh();
+      },
+      onError: () => {
+        toast({
+          description: t("common.something_went_wrong"),
+          variant: "destructive",
+        });
+        setDialogOpen(false);
+      },
+    }),
+  );
 
   const handleRegenerate = () => {
     mutator.mutate({ id });
-- 
cgit v1.2.3-70-g09d2

