From cd623ad9d6281389b0a092520c777567fcf5464b Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sat, 2 Mar 2024 14:23:46 +0000 Subject: feature: Add an 'All Lists' page --- packages/web/app/dashboard/components/AllLists.tsx | 6 +++ .../web/app/dashboard/components/ModileSidebar.tsx | 9 +++- .../lists/[listId]/components/DeleteListButton.tsx | 3 +- .../lists/[listId]/components/ListView.tsx | 12 +---- packages/web/app/dashboard/lists/[listId]/page.tsx | 14 +++++- .../dashboard/lists/components/AllListsView.tsx | 57 ++++++++++++++++++++++ packages/web/app/dashboard/lists/page.tsx | 14 ++++++ 7 files changed, 101 insertions(+), 14 deletions(-) create mode 100644 packages/web/app/dashboard/lists/components/AllListsView.tsx create mode 100644 packages/web/app/dashboard/lists/page.tsx (limited to 'packages') diff --git a/packages/web/app/dashboard/components/AllLists.tsx b/packages/web/app/dashboard/components/AllLists.tsx index 5dc36043..e2a6b777 100644 --- a/packages/web/app/dashboard/components/AllLists.tsx +++ b/packages/web/app/dashboard/components/AllLists.tsx @@ -25,6 +25,12 @@ export default function AllLists() { + 📋} + name="All Lists" + path={`/dashboard/lists`} + className="py-0.5" + /> ⭐️} name="Favourties" diff --git a/packages/web/app/dashboard/components/ModileSidebar.tsx b/packages/web/app/dashboard/components/ModileSidebar.tsx index c9a933fa..4bd6a347 100644 --- a/packages/web/app/dashboard/components/ModileSidebar.tsx +++ b/packages/web/app/dashboard/components/ModileSidebar.tsx @@ -1,5 +1,11 @@ import MobileSidebarItem from "./ModileSidebarItem"; -import { Tag, PackageOpen, Settings, Search } from "lucide-react"; +import { + Tag, + PackageOpen, + Settings, + Search, + ClipboardList, +} from "lucide-react"; import SidebarProfileOptions from "./SidebarProfileOptions"; export default async function MobileSidebar() { @@ -8,6 +14,7 @@ export default async function MobileSidebar() {
    } path="/dashboard/bookmarks" /> } path="/dashboard/search" /> + } path="/dashboard/lists" /> } path="/dashboard/tags" /> } path="/dashboard/settings" /> diff --git a/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx b/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx index 8961b2d0..32a7facf 100644 --- a/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx +++ b/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx @@ -1,9 +1,10 @@ +"use client"; + import { Button } from "@/components/ui/button"; import { Dialog, DialogClose, DialogContent, - DialogDescription, DialogFooter, DialogHeader, DialogTitle, diff --git a/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx b/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx index c3d49b6a..6489e9f0 100644 --- a/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx +++ b/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx @@ -4,7 +4,6 @@ import BookmarksGrid from "@/app/dashboard/bookmarks/components/BookmarksGrid"; import { ZBookmark } from "@/lib/types/api/bookmarks"; import { ZBookmarkListWithBookmarks } from "@/lib/types/api/lists"; import { api } from "@/lib/trpc"; -import DeleteListButton from "./DeleteListButton"; export default function ListView({ bookmarks, @@ -21,15 +20,6 @@ export default function ListView({ ); return ( -
    -
    - - {data.icon} {data.name} - - -
    -
    - -
    + ); } diff --git a/packages/web/app/dashboard/lists/[listId]/page.tsx b/packages/web/app/dashboard/lists/[listId]/page.tsx index b8ca79c3..397a0f1e 100644 --- a/packages/web/app/dashboard/lists/[listId]/page.tsx +++ b/packages/web/app/dashboard/lists/[listId]/page.tsx @@ -3,6 +3,7 @@ import { getServerAuthSession } from "@/server/auth"; import { TRPCError } from "@trpc/server"; import { notFound, redirect } from "next/navigation"; import ListView from "./components/ListView"; +import DeleteListButton from "./components/DeleteListButton"; export default async function ListPage({ params, @@ -28,5 +29,16 @@ export default async function ListPage({ const bookmarks = await api.bookmarks.getBookmarks({ ids: list.bookmarks }); - return ; + return ( +
    +
    + + {list.icon} {list.name} + + +
    +
    + +
    + ); } diff --git a/packages/web/app/dashboard/lists/components/AllListsView.tsx b/packages/web/app/dashboard/lists/components/AllListsView.tsx new file mode 100644 index 00000000..7c8a9e56 --- /dev/null +++ b/packages/web/app/dashboard/lists/components/AllListsView.tsx @@ -0,0 +1,57 @@ +"use client"; + +import LoadingSpinner from "@/components/ui/spinner"; +import { api } from "@/lib/trpc"; +import { ZBookmarkList } from "@/lib/types/api/lists"; +import { keepPreviousData } from "@tanstack/react-query"; +import Link from "next/link"; + +function ListItem({ + name, + icon, + path, +}: { + name: string; + icon: string; + path: string; +}) { + return ( + +
    +

    + {icon} {name} +

    +
    + + ); +} + +export default function AllListsView({ + initialData, +}: { + initialData: ZBookmarkList[]; +}) { + const { data: lists } = api.lists.list.useQuery(undefined, { + initialData: { lists: initialData }, + placeholderData: keepPreviousData, + }); + + if (!lists) { + return ; + } + + return ( +
    + + + {lists.lists.map((l) => ( + + ))} +
    + ); +} diff --git a/packages/web/app/dashboard/lists/page.tsx b/packages/web/app/dashboard/lists/page.tsx new file mode 100644 index 00000000..62e328b0 --- /dev/null +++ b/packages/web/app/dashboard/lists/page.tsx @@ -0,0 +1,14 @@ +import { api } from "@/server/api/client"; +import AllListsView from "./components/AllListsView"; + +export default async function ListsPage() { + const lists = await api.lists.list(); + + return ( +
    +

    📋 All Lists

    +
    + +
    + ); +} -- cgit v1.2.3-70-g09d2