From f6ca0b0c4fb3c1e6d93a00fcce7cb0aee12930c0 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sat, 16 Mar 2024 00:34:04 +0000
Subject: ui(web): Add an editor card inline in the bookmark grid and remove
 the top nav buttons

---
 .../dashboard/bookmarks/AddLinkButton.tsx          | 103 ---------------------
 1 file changed, 103 deletions(-)
 delete mode 100644 apps/web/components/dashboard/bookmarks/AddLinkButton.tsx

(limited to 'apps/web/components/dashboard/bookmarks/AddLinkButton.tsx')

diff --git a/apps/web/components/dashboard/bookmarks/AddLinkButton.tsx b/apps/web/components/dashboard/bookmarks/AddLinkButton.tsx
deleted file mode 100644
index 45a67020..00000000
--- a/apps/web/components/dashboard/bookmarks/AddLinkButton.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import type { SubmitErrorHandler } from "react-hook-form";
-import { useState } from "react";
-import { ActionButton } from "@/components/ui/action-button";
-import { Button } from "@/components/ui/button";
-import {
-  Dialog,
-  DialogClose,
-  DialogContent,
-  DialogFooter,
-  DialogHeader,
-  DialogTitle,
-  DialogTrigger,
-} from "@/components/ui/dialog";
-import { Form, FormControl, FormField, FormItem } from "@/components/ui/form";
-import { Input } from "@/components/ui/input";
-import { toast } from "@/components/ui/use-toast";
-import { api } from "@/lib/trpc";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useForm } from "react-hook-form";
-import { z } from "zod";
-
-export function AddLinkButton({ children }: { children: React.ReactNode }) {
-  const [isOpen, setOpen] = useState(false);
-
-  const formSchema = z.object({
-    url: z.string().url({ message: "The link must be a valid URL" }),
-  });
-  const form = useForm<z.infer<typeof formSchema>>({
-    resolver: zodResolver(formSchema),
-    defaultValues: {
-      url: "",
-    },
-  });
-
-  const invalidateBookmarksCache = api.useUtils().bookmarks.invalidate;
-  const createBookmarkMutator = api.bookmarks.createBookmark.useMutation({
-    onSuccess: () => {
-      invalidateBookmarksCache();
-      form.reset();
-      setOpen(false);
-    },
-    onError: () => {
-      toast({ description: "Something went wrong", variant: "destructive" });
-    },
-  });
-
-  const onError: SubmitErrorHandler<z.infer<typeof formSchema>> = (errors) => {
-    toast({
-      description: Object.values(errors)
-        .map((v) => v.message)
-        .join("\n"),
-      variant: "destructive",
-    });
-  };
-
-  return (
-    <Dialog open={isOpen} onOpenChange={setOpen}>
-      <DialogTrigger asChild>{children}</DialogTrigger>
-      <DialogContent>
-        <Form {...form}>
-          <DialogHeader>
-            <DialogTitle>Add Link</DialogTitle>
-          </DialogHeader>
-          <form
-            className="flex flex-col gap-4"
-            onSubmit={form.handleSubmit(
-              (value) =>
-                createBookmarkMutator.mutate({ url: value.url, type: "link" }),
-              onError,
-            )}
-          >
-            <FormField
-              control={form.control}
-              name="url"
-              render={({ field }) => {
-                return (
-                  <FormItem className="flex-1">
-                    <FormControl>
-                      <Input type="text" placeholder="Link" {...field} />
-                    </FormControl>
-                  </FormItem>
-                );
-              }}
-            />
-            <DialogFooter className="flex-shrink gap-1 sm:justify-end">
-              <DialogClose asChild>
-                <Button type="button" variant="secondary">
-                  Close
-                </Button>
-              </DialogClose>
-              <ActionButton
-                type="submit"
-                loading={createBookmarkMutator.isPending}
-              >
-                Add
-              </ActionButton>
-            </DialogFooter>
-          </form>
-        </Form>
-      </DialogContent>
-    </Dialog>
-  );
-}
-- 
cgit v1.2.3-70-g09d2

