aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-28 20:45:28 +0000
committerMohamedBassem <me@mbassem.com>2024-02-28 20:45:28 +0000
commit3208dda3848ad739f54cebf44c423e2b68e85b2d (patch)
tree25602c451354a296e8779197fdd42acab7526502 /packages/web/app/dashboard/bookmarks/components/AddLink.tsx
parent7096fb3941579e5c045796361745d597e03ff7fc (diff)
downloadkarakeep-3208dda3848ad739f54cebf44c423e2b68e85b2d.tar.zst
feature: Add support for storing and previewing raw notes
Diffstat (limited to 'packages/web/app/dashboard/bookmarks/components/AddLink.tsx')
-rw-r--r--packages/web/app/dashboard/bookmarks/components/AddLink.tsx71
1 files changed, 0 insertions, 71 deletions
diff --git a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx b/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
deleted file mode 100644
index 242a52a5..00000000
--- a/packages/web/app/dashboard/bookmarks/components/AddLink.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-"use client";
-
-import { Form, FormControl, FormField, FormItem } from "@/components/ui/form";
-import { Input } from "@/components/ui/input";
-import { Plus } from "lucide-react";
-import { useForm, SubmitErrorHandler } from "react-hook-form";
-import { z } from "zod";
-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";
-
-const formSchema = z.object({
- url: z.string().url({ message: "The link must be a valid URL" }),
-});
-
-export default function AddLink() {
- const form = useForm<z.infer<typeof formSchema>>({
- resolver: zodResolver(formSchema),
- });
-
- const invalidateBookmarksCache = api.useUtils().bookmarks.invalidate;
- const bookmarkLinkMutator = api.bookmarks.bookmarkLink.useMutation({
- onSuccess: () => {
- invalidateBookmarksCache();
- },
- 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 (
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit(
- (value) =>
- bookmarkLinkMutator.mutate({ url: value.url, type: "link" }),
- onError,
- )}
- >
- <div className="container flex w-full items-center space-x-2 py-4">
- <FormField
- control={form.control}
- name="url"
- render={({ field }) => {
- return (
- <FormItem className="flex-1">
- <FormControl>
- <Input type="text" placeholder="Link" {...field} />
- </FormControl>
- </FormItem>
- );
- }}
- />
- <ActionButton type="submit" loading={bookmarkLinkMutator.isPending}>
- <Plus />
- </ActionButton>
- </div>
- </form>
- </Form>
- );
-}