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/browser-extension/src/SignInPage.tsx | 32 ++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

(limited to 'apps/browser-extension/src/SignInPage.tsx')

diff --git a/apps/browser-extension/src/SignInPage.tsx b/apps/browser-extension/src/SignInPage.tsx
index 6cf8b35d..8a7229b6 100644
--- a/apps/browser-extension/src/SignInPage.tsx
+++ b/apps/browser-extension/src/SignInPage.tsx
@@ -1,11 +1,12 @@
 import { useState } from "react";
+import { useMutation } from "@tanstack/react-query";
 import { useNavigate } from "react-router-dom";
 
 import { Button } from "./components/ui/button";
 import { Input } from "./components/ui/input";
 import Logo from "./Logo";
 import usePluginSettings from "./utils/settings";
-import { api } from "./utils/trpc";
+import { useTRPC } from "./utils/trpc";
 
 const enum LoginState {
   NONE = "NONE",
@@ -14,6 +15,7 @@ const enum LoginState {
 }
 
 export default function SignInPage() {
+  const api = useTRPC();
   const navigate = useNavigate();
   const { settings, setSettings } = usePluginSettings();
 
@@ -21,23 +23,27 @@ export default function SignInPage() {
     mutate: login,
     error: usernamePasswordError,
     isPending: userNamePasswordRequestIsPending,
-  } = api.apiKeys.exchange.useMutation({
-    onSuccess: (resp) => {
-      setSettings((s) => ({ ...s, apiKey: resp.key, apiKeyId: resp.id }));
-      navigate("/options");
-    },
-  });
+  } = useMutation(
+    api.apiKeys.exchange.mutationOptions({
+      onSuccess: (resp) => {
+        setSettings((s) => ({ ...s, apiKey: resp.key, apiKeyId: resp.id }));
+        navigate("/options");
+      },
+    }),
+  );
 
   const {
     mutate: validateApiKey,
     error: apiKeyValidationError,
     isPending: apiKeyValueRequestIsPending,
-  } = api.apiKeys.validate.useMutation({
-    onSuccess: () => {
-      setSettings((s) => ({ ...s, apiKey: apiKeyFormData.apiKey }));
-      navigate("/options");
-    },
-  });
+  } = useMutation(
+    api.apiKeys.validate.mutationOptions({
+      onSuccess: () => {
+        setSettings((s) => ({ ...s, apiKey: apiKeyFormData.apiKey }));
+        navigate("/options");
+      },
+    }),
+  );
 
   const [lastLoginAttemptSource, setLastLoginAttemptSource] =
     useState<LoginState>(LoginState.NONE);
-- 
cgit v1.2.3-70-g09d2

