From 2ac3c39a9c80305bb959d88561e78f65a1cd1be1 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Thu, 22 Feb 2024 17:33:12 +0000
Subject: feature: Adding some loading card while the link is getting crawled

---
 .../web/app/dashboard/bookmarks/components/AddLink.tsx   | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

(limited to 'packages/web/app/dashboard/bookmarks/components/AddLink.tsx')

diff --git a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
index 7663543f..242a52a5 100644
--- a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
+++ b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
@@ -9,32 +9,24 @@ import { zodResolver } from "@hookform/resolvers/zod";
 import { toast } from "@/components/ui/use-toast";
 import { api } from "@/lib/trpc";
 import { ActionButton } from "@/components/ui/action-button";
-import { useLoadingCard } from "@/lib/hooks/use-loading-card";
 
 const formSchema = z.object({
   url: z.string().url({ message: "The link must be a valid URL" }),
 });
 
 export default function AddLink() {
-  const { setLoading } = useLoadingCard();
+  const form = useForm<z.infer<typeof formSchema>>({
+    resolver: zodResolver(formSchema),
+  });
+
   const invalidateBookmarksCache = api.useUtils().bookmarks.invalidate;
   const bookmarkLinkMutator = api.bookmarks.bookmarkLink.useMutation({
-    onMutate: () => {
-      setLoading(true);
-    },
     onSuccess: () => {
       invalidateBookmarksCache();
     },
     onError: () => {
       toast({ description: "Something went wrong", variant: "destructive" });
     },
-    onSettled: () => {
-      setLoading(false);
-    },
-  });
-
-  const form = useForm<z.infer<typeof formSchema>>({
-    resolver: zodResolver(formSchema),
   });
 
   const onError: SubmitErrorHandler<z.infer<typeof formSchema>> = (errors) => {
-- 
cgit v1.2.3-70-g09d2

