From 88b92d8eb2a203f7092314a5d9c9a7070b568b6d Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Tue, 23 Apr 2024 20:11:25 +0100 Subject: feature(web): Change the AddList modal to allow adding and removing bookmarks from lists --- .../dashboard/bookmarks/AddToListModal.tsx | 132 --------------------- 1 file changed, 132 deletions(-) delete mode 100644 apps/web/components/dashboard/bookmarks/AddToListModal.tsx (limited to 'apps/web/components/dashboard/bookmarks/AddToListModal.tsx') diff --git a/apps/web/components/dashboard/bookmarks/AddToListModal.tsx b/apps/web/components/dashboard/bookmarks/AddToListModal.tsx deleted file mode 100644 index 3b8a6700..00000000 --- a/apps/web/components/dashboard/bookmarks/AddToListModal.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import { useState } from "react"; -import { ActionButton } from "@/components/ui/action-button"; -import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogClose, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, -} from "@/components/ui/dialog"; -import { - Form, - FormControl, - FormField, - FormItem, - FormMessage, -} from "@/components/ui/form"; -import { toast } from "@/components/ui/use-toast"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; - -import { useAddBookmarkToList } from "@hoarder/shared-react/hooks/lists"; - -import { BookmarkListSelector } from "../lists/BookmarkListSelector"; - -export default function AddToListModal({ - bookmarkId, - open, - setOpen, -}: { - bookmarkId: string; - open: boolean; - setOpen: (open: boolean) => void; -}) { - const formSchema = z.object({ - listId: z.string({ - required_error: "Please select a list", - }), - }); - const form = useForm>({ - resolver: zodResolver(formSchema), - }); - - const { mutate: addToList, isPending: isAddingToListPending } = - useAddBookmarkToList({ - onSuccess: () => { - toast({ - description: "List has been updated!", - }); - setOpen(false); - }, - onError: (e) => { - if (e.data?.code == "BAD_REQUEST") { - toast({ - variant: "destructive", - description: e.message, - }); - } else { - toast({ - variant: "destructive", - title: "Something went wrong", - }); - } - }, - }); - - return ( - - -
- { - addToList({ - bookmarkId: bookmarkId, - listId: value.listId, - }); - })} - > - - Add to List - - -
- { - return ( - - - - - - - ); - }} - /> -
- - - - - - Add - - -
- -
-
- ); -} - -export function useAddToListModal(bookmarkId: string) { - const [open, setOpen] = useState(false); - - return { - open, - setOpen, - content: ( - - ), - }; -} -- cgit v1.2.3-70-g09d2