aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-17 12:54:43 +0000
committerMohamedBassem <me@mbassem.com>2024-02-17 12:54:43 +0000
commitf9878736a2f0a695829a20ba4bcd33337c3a1880 (patch)
treee144e000c18b1812eb62ebfa674326cd8d8e1259 /packages/web/app/dashboard/bookmarks/components/AddLink.tsx
parent5a3fd2d7573c62467a40c919244d12b468458a38 (diff)
downloadkarakeep-f9878736a2f0a695829a20ba4bcd33337c3a1880.tar.zst
feature: Inital attempt at showing a skeleton card while bookmark is loaded
Diffstat (limited to 'packages/web/app/dashboard/bookmarks/components/AddLink.tsx')
-rw-r--r--packages/web/app/dashboard/bookmarks/components/AddLink.tsx8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
index 0ef4d193..6cd51c1d 100644
--- a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
+++ b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
@@ -10,6 +10,7 @@ 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" }),
@@ -17,13 +18,20 @@ const formSchema = z.object({
export default function AddLink() {
const router = useRouter();
+ const {setLoading} = useLoadingCard();
const bookmarkLinkMutator = api.bookmarks.bookmarkLink.useMutation({
+ onMutate: () => {
+ setLoading(true);
+ },
onSuccess: () => {
router.refresh();
},
onError: () => {
toast({ description: "Something went wrong", variant: "destructive" });
},
+ onSettled: () => {
+ setLoading(false);
+ },
});
const form = useForm<z.infer<typeof formSchema>>({