From e0999f701cd1834c3d940113cd8dd5247c5fe95f Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Fri, 19 Apr 2024 00:09:27 +0100 Subject: feature: Nested lists (#110). Fixes #62 * feature: Add support for nested lists * prevent moving the parent to a subtree --- .../dashboard/bookmarks/AddToListModal.tsx | 79 ++---- .../components/dashboard/lists/AllListsView.tsx | 113 ++++++--- .../dashboard/lists/BookmarkListSelector.tsx | 63 +++++ .../dashboard/lists/CollapsibleBookmarkLists.tsx | 111 +++++++++ .../dashboard/lists/DeleteListButton.tsx | 53 ---- .../lists/DeleteListConfirmationDialog.tsx | 61 +++++ .../components/dashboard/lists/EditListModal.tsx | 276 +++++++++++++++++++++ apps/web/components/dashboard/lists/ListHeader.tsx | 46 ++++ .../web/components/dashboard/lists/ListOptions.tsx | 71 ++++++ apps/web/components/dashboard/sidebar/AllLists.tsx | 79 ++++-- .../components/dashboard/sidebar/NewListModal.tsx | 174 ------------- .../components/dashboard/sidebar/SidebarItem.tsx | 22 +- 12 files changed, 797 insertions(+), 351 deletions(-) create mode 100644 apps/web/components/dashboard/lists/BookmarkListSelector.tsx create mode 100644 apps/web/components/dashboard/lists/CollapsibleBookmarkLists.tsx delete mode 100644 apps/web/components/dashboard/lists/DeleteListButton.tsx create mode 100644 apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx create mode 100644 apps/web/components/dashboard/lists/EditListModal.tsx create mode 100644 apps/web/components/dashboard/lists/ListHeader.tsx create mode 100644 apps/web/components/dashboard/lists/ListOptions.tsx delete mode 100644 apps/web/components/dashboard/sidebar/NewListModal.tsx (limited to 'apps/web/components/dashboard') diff --git a/apps/web/components/dashboard/bookmarks/AddToListModal.tsx b/apps/web/components/dashboard/bookmarks/AddToListModal.tsx index bfe6d53f..3b8a6700 100644 --- a/apps/web/components/dashboard/bookmarks/AddToListModal.tsx +++ b/apps/web/components/dashboard/bookmarks/AddToListModal.tsx @@ -16,21 +16,15 @@ import { FormItem, FormMessage, } from "@/components/ui/form"; -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import LoadingSpinner from "@/components/ui/spinner"; import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; 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, @@ -49,20 +43,13 @@ export default function AddToListModal({ resolver: zodResolver(formSchema), }); - const { data: lists, isPending: isFetchingListsPending } = - api.lists.list.useQuery(); - - const bookmarksInvalidationFunction = - api.useUtils().bookmarks.getBookmarks.invalidate; - const { mutate: addToList, isPending: isAddingToListPending } = - api.lists.addToList.useMutation({ - onSuccess: (_resp, req) => { + useAddBookmarkToList({ + onSuccess: () => { toast({ description: "List has been updated!", }); setOpen(false); - bookmarksInvalidationFunction({ listId: req.listId }); }, onError: (e) => { if (e.data?.code == "BAD_REQUEST") { @@ -79,8 +66,6 @@ export default function AddToListModal({ }, }); - const isPending = isFetchingListsPending || isAddingToListPending; - return ( @@ -98,42 +83,20 @@ export default function AddToListModal({
- {lists ? ( - { - return ( - - - - - - - ); - }} - /> - ) : ( - - )} + { + return ( + + + + + + + ); + }} + />
@@ -144,7 +107,7 @@ export default function AddToListModal({ Add diff --git a/apps/web/components/dashboard/lists/AllListsView.tsx b/apps/web/components/dashboard/lists/AllListsView.tsx index 00e76a23..308af5db 100644 --- a/apps/web/components/dashboard/lists/AllListsView.tsx +++ b/apps/web/components/dashboard/lists/AllListsView.tsx @@ -1,31 +1,59 @@ "use client"; import Link from "next/link"; -import { useNewListModal } from "@/components/dashboard/sidebar/NewListModal"; +import { EditListModal } from "@/components/dashboard/lists/EditListModal"; import { Button } from "@/components/ui/button"; -import { api } from "@/lib/trpc"; -import { keepPreviousData } from "@tanstack/react-query"; -import { Plus } from "lucide-react"; +import { CollapsibleTriggerChevron } from "@/components/ui/collapsible"; +import { MoreHorizontal, Plus } from "lucide-react"; import type { ZBookmarkList } from "@hoarder/shared/types/lists"; +import { CollapsibleBookmarkLists } from "./CollapsibleBookmarkLists"; +import { ListOptions } from "./ListOptions"; + function ListItem({ name, icon, path, + style, + list, + open, + collapsible, }: { name: string; icon: string; path: string; + style?: React.CSSProperties; + list?: ZBookmarkList; + open?: boolean; + collapsible: boolean; }) { return ( - -
-

- {icon} {name} -

-
- +
  • + + {collapsible && ( + + )} + +

    + {icon} {name} +

    + +
    + {list && ( + + + + )} +
  • ); } @@ -34,34 +62,41 @@ export default function AllListsView({ }: { 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) => ( - - ))} -
    +
      + + + + + + ( + 0} + open={open} + style={{ marginLeft: `${level * 1}rem` }} + /> + )} + /> +
    ); } diff --git a/apps/web/components/dashboard/lists/BookmarkListSelector.tsx b/apps/web/components/dashboard/lists/BookmarkListSelector.tsx new file mode 100644 index 00000000..fdae1c17 --- /dev/null +++ b/apps/web/components/dashboard/lists/BookmarkListSelector.tsx @@ -0,0 +1,63 @@ +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import LoadingSpinner from "@/components/ui/spinner"; + +import { useBookmarkLists } from "@hoarder/shared-react/hooks/lists"; + +export function BookmarkListSelector({ + value, + onChange, + hideSubtreeOf, + placeholder = "Select a list", +}: { + value?: string | null; + onChange: (value: string) => void; + placeholder?: string; + hideSubtreeOf?: string; +}) { + const { data, isPending: isFetchingListsPending } = useBookmarkLists(); + let { allPaths } = data ?? {}; + + if (isFetchingListsPending) { + return ; + } + + allPaths = allPaths?.filter((path) => { + if (!hideSubtreeOf) { + return true; + } + return !path.map((p) => p.id).includes(hideSubtreeOf); + }); + + return ( + + ); +} diff --git a/apps/web/components/dashboard/lists/CollapsibleBookmarkLists.tsx b/apps/web/components/dashboard/lists/CollapsibleBookmarkLists.tsx new file mode 100644 index 00000000..da1b7408 --- /dev/null +++ b/apps/web/components/dashboard/lists/CollapsibleBookmarkLists.tsx @@ -0,0 +1,111 @@ +import { useEffect, useState } from "react"; +import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible"; +import { FullPageSpinner } from "@/components/ui/full-page-spinner"; + +import { + augmentBookmarkListsWithInitialData, + useBookmarkLists, +} from "@hoarder/shared-react/hooks/lists"; +import { ZBookmarkList } from "@hoarder/shared/types/lists"; +import { ZBookmarkListTreeNode } from "@hoarder/shared/utils/listUtils"; + +type RenderFunc = (params: { + item: ZBookmarkListTreeNode; + level: number; + open: boolean; +}) => React.ReactNode; + +type IsOpenFunc = (list: ZBookmarkListTreeNode) => boolean; + +function ListItem({ + node, + render, + level, + className, + isOpenFunc, +}: { + node: ZBookmarkListTreeNode; + render: RenderFunc; + isOpenFunc: IsOpenFunc; + level: number; + className?: string; +}) { + // Not the most efficient way to do this, but it works for now + const isAnyChildOpen = ( + node: ZBookmarkListTreeNode, + isOpenFunc: IsOpenFunc, + ): boolean => { + if (isOpenFunc(node)) { + return true; + } + return node.children.some((l) => isAnyChildOpen(l, isOpenFunc)); + }; + const [open, setOpen] = useState(false); + useEffect(() => { + setOpen((curr) => curr || isAnyChildOpen(node, isOpenFunc)); + }, [node, isOpenFunc]); + + return ( + + {render({ + item: node, + level, + open, + })} + + {node.children.map((l) => ( + + ))} + + + ); +} + +export function CollapsibleBookmarkLists({ + render, + initialData, + className, + isOpenFunc, +}: { + initialData?: ZBookmarkList[]; + render: RenderFunc; + isOpenFunc?: IsOpenFunc; + className?: string; +}) { + let { data } = useBookmarkLists(undefined, { + initialData: initialData ? { lists: initialData } : undefined, + }); + + // TODO: This seems to be a bug in react query + if (initialData) { + data = augmentBookmarkListsWithInitialData(data, initialData); + } + + if (!data) { + return ; + } + + const { root } = data; + + return ( +
    + {Object.values(root).map((l) => ( + false)} + /> + ))} +
    + ); +} diff --git a/apps/web/components/dashboard/lists/DeleteListButton.tsx b/apps/web/components/dashboard/lists/DeleteListButton.tsx deleted file mode 100644 index 774b79ac..00000000 --- a/apps/web/components/dashboard/lists/DeleteListButton.tsx +++ /dev/null @@ -1,53 +0,0 @@ -"use client"; - -import { useRouter } from "next/navigation"; -import { ActionButton } from "@/components/ui/action-button"; -import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog"; -import { Button } from "@/components/ui/button"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { Trash2 } from "lucide-react"; - -import type { ZBookmarkList } from "@hoarder/shared/types/lists"; - -export default function DeleteListButton({ list }: { list: ZBookmarkList }) { - 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 ( - ( - deleteList({ listId: list.id })} - > - Delete - - )} - > - - - ); -} diff --git a/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx b/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx new file mode 100644 index 00000000..bf1969bf --- /dev/null +++ b/apps/web/components/dashboard/lists/DeleteListConfirmationDialog.tsx @@ -0,0 +1,61 @@ +import { usePathname, useRouter } from "next/navigation"; +import { ActionButton } from "@/components/ui/action-button"; +import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog"; +import { toast } from "@/components/ui/use-toast"; + +import type { ZBookmarkList } from "@hoarder/shared/types/lists"; +import { useDeleteBookmarkList } from "@hoarder/shared-react/hooks/lists"; + +export default function DeleteListConfirmationDialog({ + list, + children, + open, + setOpen, +}: { + list: ZBookmarkList; + children?: React.ReactNode; + open: boolean; + setOpen: (v: boolean) => void; +}) { + const currentPath = usePathname(); + const router = useRouter(); + + const { mutate: deleteList, isPending } = useDeleteBookmarkList({ + onSuccess: () => { + toast({ + description: `List "${list.icon} ${list.name}" is deleted!`, + }); + setOpen(false); + if (currentPath.includes(list.id)) { + router.push("/dashboard/lists"); + } + }, + onError: () => { + toast({ + variant: "destructive", + description: `Something went wrong`, + }); + }, + }); + + return ( + ( + deleteList({ listId: list.id })} + > + Delete + + )} + > + {children} + + ); +} diff --git a/apps/web/components/dashboard/lists/EditListModal.tsx b/apps/web/components/dashboard/lists/EditListModal.tsx new file mode 100644 index 00000000..993c975b --- /dev/null +++ b/apps/web/components/dashboard/lists/EditListModal.tsx @@ -0,0 +1,276 @@ +import { useEffect, useState } from "react"; +import { useRouter } from "next/navigation"; +import { ActionButton } from "@/components/ui/action-button"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogClose, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { toast } from "@/components/ui/use-toast"; +import data from "@emoji-mart/data"; +import Picker from "@emoji-mart/react"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { X } from "lucide-react"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; + +import { + useCreateBookmarkList, + useEditBookmarkList, +} from "@hoarder/shared-react/hooks/lists"; +import { ZBookmarkList } from "@hoarder/shared/types/lists"; + +import { BookmarkListSelector } from "./BookmarkListSelector"; + +export function EditListModal({ + open: userOpen, + setOpen: userSetOpen, + list, + parent, + children, +}: { + open?: boolean; + setOpen?: (v: boolean) => void; + list?: ZBookmarkList; + parent?: ZBookmarkList; + children?: React.ReactNode; +}) { + const router = useRouter(); + if ( + (userOpen !== undefined && !userSetOpen) || + (userOpen === undefined && userSetOpen) + ) { + throw new Error("You must provide both open and setOpen or neither"); + } + const [customOpen, customSetOpen] = useState(false); + const formSchema = z.object({ + name: z.string(), + icon: z.string(), + parentId: z.string().nullish(), + }); + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + name: list?.name ?? "", + icon: list?.icon ?? "🚀", + parentId: list?.parentId ?? parent?.id, + }, + }); + const [open, setOpen] = [ + userOpen ?? customOpen, + userSetOpen ?? customSetOpen, + ]; + + useEffect(() => { + form.reset({ + name: list?.name ?? "", + icon: list?.icon ?? "🚀", + parentId: list?.parentId ?? parent?.id, + }); + }, [open]); + + const { mutate: createList, isPending: isCreating } = useCreateBookmarkList({ + onSuccess: (resp) => { + toast({ + description: "List has been created!", + }); + setOpen(false); + router.push(`/dashboard/lists/${resp.id}`); + form.reset(); + }, + onError: (e) => { + if (e.data?.code == "BAD_REQUEST") { + if (e.data.zodError) { + toast({ + variant: "destructive", + description: Object.values(e.data.zodError.fieldErrors) + .flat() + .join("\n"), + }); + } else { + toast({ + variant: "destructive", + description: e.message, + }); + } + } else { + toast({ + variant: "destructive", + title: "Something went wrong", + }); + } + }, + }); + + const { mutate: editList, isPending: isEditing } = useEditBookmarkList({ + onSuccess: () => { + toast({ + description: "List has been updated!", + }); + setOpen(false); + form.reset(); + }, + onError: (e) => { + if (e.data?.code == "BAD_REQUEST") { + if (e.data.zodError) { + toast({ + variant: "destructive", + description: Object.values(e.data.zodError.fieldErrors) + .flat() + .join("\n"), + }); + } else { + toast({ + variant: "destructive", + description: e.message, + }); + } + } else { + toast({ + variant: "destructive", + title: "Something went wrong", + }); + } + }, + }); + + const isEdit = !!list; + const isPending = isCreating || isEditing; + + return ( + { + form.reset(); + setOpen(s); + }} + > + {children && {children}} + +
    + { + value.parentId = value.parentId === "" ? null : value.parentId; + isEdit + ? editList({ ...value, listId: list.id }) + : createList(value); + })} + > + + {isEdit ? "Edit" : "New"} List + +
    + { + return ( + + + + + {field.value} + + + + field.onChange(e.native) + } + /> + + + + + + ); + }} + /> + + { + return ( + + + + + + + ); + }} + /> +
    + { + return ( + + Parent +
    + + + + +
    + +
    + ); + }} + /> + + + + + + {list ? "Save" : "Create"} + + + + +
    +
    + ); +} diff --git a/apps/web/components/dashboard/lists/ListHeader.tsx b/apps/web/components/dashboard/lists/ListHeader.tsx new file mode 100644 index 00000000..6796d484 --- /dev/null +++ b/apps/web/components/dashboard/lists/ListHeader.tsx @@ -0,0 +1,46 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { Button } from "@/components/ui/button"; +import { MoreHorizontal } from "lucide-react"; + +import { api } from "@hoarder/shared-react/trpc"; +import { ZBookmarkList } from "@hoarder/shared/types/lists"; + +import { ListOptions } from "./ListOptions"; + +export default function ListHeader({ + initialData, +}: { + initialData: ZBookmarkList & { bookmarks: string[] }; +}) { + const router = useRouter(); + const { data: list, error } = api.lists.get.useQuery( + { + listId: initialData.id, + }, + { + initialData, + }, + ); + + if (error) { + // This is usually exercised during list deletions. + if (error.data?.code == "NOT_FOUND") { + router.push("/dashboard/lists"); + } + } + + return ( +
    + + {list.icon} {list.name} + + + + +
    + ); +} diff --git a/apps/web/components/dashboard/lists/ListOptions.tsx b/apps/web/components/dashboard/lists/ListOptions.tsx new file mode 100644 index 00000000..b44d8a23 --- /dev/null +++ b/apps/web/components/dashboard/lists/ListOptions.tsx @@ -0,0 +1,71 @@ +"use client"; + +import { useState } from "react"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Pencil, Plus, Trash2 } from "lucide-react"; + +import { ZBookmarkList } from "@hoarder/shared/types/lists"; + +import { EditListModal } from "../lists/EditListModal"; +import DeleteListConfirmationDialog from "./DeleteListConfirmationDialog"; + +export function ListOptions({ + list, + children, +}: { + list: ZBookmarkList; + children?: React.ReactNode; +}) { + const [deleteListDialogOpen, setDeleteListDialogOpen] = useState(false); + const [newNestedListModalOpen, setNewNestedListModalOpen] = useState(false); + const [editModalOpen, setEditModalOpen] = useState(false); + + return ( + + + + + {children} + + setEditModalOpen(true)} + > + + Edit + + setNewNestedListModalOpen(true)} + > + + New nested list + + setDeleteListDialogOpen(true)} + > + + Delete + + + + ); +} diff --git a/apps/web/components/dashboard/sidebar/AllLists.tsx b/apps/web/components/dashboard/sidebar/AllLists.tsx index 6ab42851..b1c6ddb2 100644 --- a/apps/web/components/dashboard/sidebar/AllLists.tsx +++ b/apps/web/components/dashboard/sidebar/AllLists.tsx @@ -1,12 +1,18 @@ "use client"; +import { useCallback } from "react"; import Link from "next/link"; -import { api } from "@/lib/trpc"; -import { Plus } from "lucide-react"; +import { usePathname } from "next/navigation"; +import { Button } from "@/components/ui/button"; +import { CollapsibleTriggerTriangle } from "@/components/ui/collapsible"; +import { MoreHorizontal, Plus } from "lucide-react"; import type { ZBookmarkList } from "@hoarder/shared/types/lists"; +import { ZBookmarkListTreeNode } from "@hoarder/shared/utils/listUtils"; -import NewListModal, { useNewListModal } from "./NewListModal"; +import { CollapsibleBookmarkLists } from "../lists/CollapsibleBookmarkLists"; +import { EditListModal } from "../lists/EditListModal"; +import { ListOptions } from "../lists/ListOptions"; import SidebarItem from "./SidebarItem"; export default function AllLists({ @@ -14,21 +20,20 @@ export default function AllLists({ }: { initialData: { lists: ZBookmarkList[] }; }) { - let { data: lists } = api.lists.list.useQuery(undefined, { - initialData, - }); - // TODO: This seems to be a bug in react query - lists ||= initialData; - const { setOpen } = useNewListModal(); - + const pathName = usePathname(); + const isNodeOpen = useCallback( + (node: ZBookmarkListTreeNode) => pathName.includes(node.item.id), + [pathName], + ); return (
      -
    • Lists

      - setOpen(true)}> - - + + + + +
    • 📋} @@ -48,15 +53,45 @@ export default function AllLists({ path={`/dashboard/archive`} className="py-0.5" /> - {lists.lists.map((l) => ( - {l.icon}} - name={l.name} - path={`/dashboard/lists/${l.id}`} - className="py-0.5" + + { + ( + 0 && ( + + ) + } + logo={ + + {node.item.icon} + + } + name={node.item.name} + path={`/dashboard/lists/${node.item.id}`} + right={ + + + + } + className="group py-0.5" + style={{ marginLeft: `${level * 1}rem` }} + /> + )} /> - ))} + }
    ); } diff --git a/apps/web/components/dashboard/sidebar/NewListModal.tsx b/apps/web/components/dashboard/sidebar/NewListModal.tsx deleted file mode 100644 index 5169fbb5..00000000 --- a/apps/web/components/dashboard/sidebar/NewListModal.tsx +++ /dev/null @@ -1,174 +0,0 @@ -"use client"; - -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 { Input } from "@/components/ui/input"; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import data from "@emoji-mart/data"; -import Picker from "@emoji-mart/react"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; -import { z } from "zod"; -import { create } from "zustand"; - -export const useNewListModal = create<{ - open: boolean; - setOpen: (v: boolean) => void; -}>((set) => ({ - open: false, - setOpen: (open: boolean) => set(() => ({ open })), -})); - -export default function NewListModal() { - const { open, setOpen } = useNewListModal(); - - const formSchema = z.object({ - name: z.string(), - icon: z.string(), - }); - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - name: "", - icon: "🚀", - }, - }); - - const listsInvalidationFunction = api.useUtils().lists.list.invalidate; - - const { mutate: createList, isPending } = api.lists.create.useMutation({ - onSuccess: () => { - toast({ - description: "List has been created!", - }); - listsInvalidationFunction(); - setOpen(false); - form.reset(); - }, - onError: (e) => { - if (e.data?.code == "BAD_REQUEST") { - if (e.data.zodError) { - toast({ - variant: "destructive", - description: Object.values(e.data.zodError.fieldErrors) - .flat() - .join("\n"), - }); - } else { - toast({ - variant: "destructive", - description: e.message, - }); - } - } else { - toast({ - variant: "destructive", - title: "Something went wrong", - }); - } - }, - }); - - return ( - { - form.reset(); - setOpen(s); - }} - > - -
    - { - createList(value); - })} - > - - New List - -
    - { - return ( - - - - - {field.value} - - - - field.onChange(e.native) - } - /> - - - - - - ); - }} - /> - - { - return ( - - - - - - - ); - }} - /> -
    - - - - - - Create - - -
    - -
    -
    - ); -} diff --git a/apps/web/components/dashboard/sidebar/SidebarItem.tsx b/apps/web/components/dashboard/sidebar/SidebarItem.tsx index 7e5eb3bd..262fd9ae 100644 --- a/apps/web/components/dashboard/sidebar/SidebarItem.tsx +++ b/apps/web/components/dashboard/sidebar/SidebarItem.tsx @@ -1,5 +1,6 @@ "use client"; +import React from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { cn } from "@/lib/utils"; @@ -9,25 +10,36 @@ export default function SidebarItem({ logo, path, className, + style, + collapseButton, + right = null, }: { name: string; logo: React.ReactNode; path: string; + style?: React.CSSProperties; className?: string; + right?: React.ReactNode; + collapseButton?: React.ReactNode; }) { const currentPath = usePathname(); return (
  • - - {logo} - {name} - + {collapseButton} +
    + + {logo} + {name} + + {right} +
  • ); } -- cgit v1.2.3-70-g09d2