Skip to content

Commit

Permalink
feature: Add 'New List' button in the all lists page
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Mar 2, 2024
1 parent cd623ad commit 3324f44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/web/app/dashboard/components/NewListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function NewListModal() {
})}
>
<DialogHeader>
<DialogTitle>Create List</DialogTitle>
<DialogTitle>New List</DialogTitle>
</DialogHeader>
<div className="flex w-full gap-2 py-4">
<FormField
Expand Down
13 changes: 12 additions & 1 deletion packages/web/app/dashboard/lists/components/AllListsView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"use client";

import { Button } from "@/components/ui/button";
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 { Plus } from "lucide-react";
import Link from "next/link";
import { useNewListModal } from "../../components/NewListModal";

function ListItem({
name,
Expand All @@ -31,6 +34,7 @@ export default function AllListsView({
}: {
initialData: ZBookmarkList[];
}) {
const { setOpen: setIsNewListModalOpen } = useNewListModal();
const { data: lists } = api.lists.list.useQuery(undefined, {
initialData: { lists: initialData },
placeholderData: keepPreviousData,
Expand All @@ -41,7 +45,14 @@ export default function AllListsView({
}

return (
<div className="flex flex-col gap-2 md:flex-row">
<div className="flex flex-col flex-wrap gap-2 md:flex-row">
<Button
className="my-auto flex h-full"
onClick={() => setIsNewListModalOpen(true)}
>
<Plus />
<span className="my-auto">New List</span>
</Button>
<ListItem name="Favourites" icon="⭐️" path={`/dashboard/favourites`} />
<ListItem name="Archive" icon="🗄️" path={`/dashboard/archive`} />
{lists.lists.map((l) => (
Expand Down

0 comments on commit 3324f44

Please sign in to comment.