From 04572a8e5081b1e4871e273cde9dbaaa44c52fe0 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 21:43:44 +0000 Subject: structure: Create apps dir and copy tooling dir from t3-turbo repo --- .../components/dashboard/lists/AllListsView.tsx | 66 ------------------- .../dashboard/lists/DeleteListButton.tsx | 77 ---------------------- .../web/components/dashboard/lists/ListView.tsx | 25 ------- 3 files changed, 168 deletions(-) delete mode 100644 packages/web/components/dashboard/lists/AllListsView.tsx delete mode 100644 packages/web/components/dashboard/lists/DeleteListButton.tsx delete mode 100644 packages/web/components/dashboard/lists/ListView.tsx (limited to 'packages/web/components/dashboard/lists') diff --git a/packages/web/components/dashboard/lists/AllListsView.tsx b/packages/web/components/dashboard/lists/AllListsView.tsx deleted file mode 100644 index 81f31cde..00000000 --- a/packages/web/components/dashboard/lists/AllListsView.tsx +++ /dev/null @@ -1,66 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { api } from "@/lib/trpc"; -import { ZBookmarkList } from "@hoarder/trpc/types/lists"; -import { keepPreviousData } from "@tanstack/react-query"; -import { Plus } from "lucide-react"; -import Link from "next/link"; -import { useNewListModal } from "@/components/dashboard/sidebar/NewListModal"; - -function ListItem({ - name, - icon, - path, -}: { - name: string; - icon: string; - path: string; -}) { - return ( - -
-

- {icon} {name} -

-
- - ); -} - -export default function AllListsView({ - initialData, -}: { - initialData: ZBookmarkList[]; -}) { - const { setOpen: setIsNewListModalOpen } = useNewListModal(); - let { data: lists } = api.lists.list.useQuery(undefined, { - initialData: { lists: initialData }, - placeholderData: keepPreviousData, - }); - - // TODO: This seems to be a bug in react query - lists ||= { lists: initialData }; - - return ( -
- - - - {lists.lists.map((l) => ( - - ))} -
- ); -} diff --git a/packages/web/components/dashboard/lists/DeleteListButton.tsx b/packages/web/components/dashboard/lists/DeleteListButton.tsx deleted file mode 100644 index 5303b217..00000000 --- a/packages/web/components/dashboard/lists/DeleteListButton.tsx +++ /dev/null @@ -1,77 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogClose, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; -import { Trash } from "lucide-react"; -import { useRouter } from "next/navigation"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { ActionButton } from "@/components/ui/action-button"; -import { useState } from "react"; -import { ZBookmarkList } from "@hoarder/trpc/types/lists"; - -export default function DeleteListButton({ list }: { list: ZBookmarkList }) { - const [isDialogOpen, setDialogOpen] = useState(false); - - const router = useRouter(); - - const listsInvalidationFunction = api.useUtils().lists.list.invalidate; - const { mutate: deleteList, isPending } = api.lists.delete.useMutation({ - onSuccess: () => { - listsInvalidationFunction(); - toast({ - description: `List "${list.icon} ${list.name}" is deleted!`, - }); - router.push("/"); - }, - onError: () => { - toast({ - variant: "destructive", - description: `Something went wrong`, - }); - }, - }); - return ( - - - - - - - - Delete {list.icon} {list.name}? - - - - Are you sure you want to delete {list.icon} {list.name}? - - - - - - deleteList({ listId: list.id })} - > - Delete - - - - - ); -} diff --git a/packages/web/components/dashboard/lists/ListView.tsx b/packages/web/components/dashboard/lists/ListView.tsx deleted file mode 100644 index 2d48d9e3..00000000 --- a/packages/web/components/dashboard/lists/ListView.tsx +++ /dev/null @@ -1,25 +0,0 @@ -"use client"; - -import BookmarksGrid from "@/components/dashboard/bookmarks/BookmarksGrid"; -import { ZBookmark } from "@hoarder/trpc/types/bookmarks"; -import { ZBookmarkListWithBookmarks } from "@hoarder/trpc/types/lists"; -import { api } from "@/lib/trpc"; - -export default function ListView({ - bookmarks, - list: initialData, -}: { - list: ZBookmarkListWithBookmarks; - bookmarks: ZBookmark[]; -}) { - const { data } = api.lists.get.useQuery( - { listId: initialData.id }, - { - initialData, - }, - ); - - return ( - - ); -} -- cgit v1.2.3-70-g09d2