diff --git a/apps/web/src/components/CheckboxDropdown.tsx b/apps/web/src/components/CheckboxDropdown.tsx index a710a4f4..e10d39fa 100644 --- a/apps/web/src/components/CheckboxDropdown.tsx +++ b/apps/web/src/components/CheckboxDropdown.tsx @@ -113,7 +113,7 @@ export default function CheckboxDropdown({ <> {children} diff --git a/apps/web/src/views/card/components/Dropdown.tsx b/apps/web/src/views/card/components/Dropdown.tsx index c23a01b2..cc02d754 100644 --- a/apps/web/src/views/card/components/Dropdown.tsx +++ b/apps/web/src/views/card/components/Dropdown.tsx @@ -1,44 +1,22 @@ -import { Fragment } from "react"; -import { Menu, Transition } from "@headlessui/react"; -import { HiEllipsisHorizontal } from "react-icons/hi2"; +import { HiEllipsisHorizontal, HiOutlineTrash } from "react-icons/hi2"; + +import Dropdown from "~/components/Dropdown"; import { useModal } from "~/providers/modal"; -export default function Dropdown() { +export default function BoardDropdown() { const { openModal } = useModal(); return ( - -
- - - -
- - - -
- - - -
-
-
-
+ openModal("DELETE_CARD"), + icon: , + }, + ]} + > + + ); } diff --git a/apps/web/src/views/card/components/ListSelector.tsx b/apps/web/src/views/card/components/ListSelector.tsx index b9e7fe0c..d84ada1a 100644 --- a/apps/web/src/views/card/components/ListSelector.tsx +++ b/apps/web/src/views/card/components/ListSelector.tsx @@ -1,13 +1,13 @@ -import { Fragment } from "react"; +import { Menu } from "@headlessui/react"; + +import CheckboxDropdown from "~/components/CheckboxDropdown"; import { api } from "~/utils/api"; -import { Menu, Transition } from "@headlessui/react"; -import { useForm } from "react-hook-form"; interface ListSelectorProps { cardPublicId: string; lists: { - publicId: string; - name: string; + key: string; + value: string; selected: boolean; }[]; isLoading: boolean; @@ -28,16 +28,6 @@ export default function ListSelector({ }, }); - const { register, handleSubmit, setValue, watch } = useForm({ - values: Object.fromEntries( - lists?.map((list) => [list.publicId, list.selected]) ?? [], - ), - }); - - const onSubmit = (values: Record) => { - console.log({ values }); - }; - const selectedList = lists.find((list) => list.selected); return ( @@ -47,67 +37,20 @@ export default function ListSelector({
) : ( - + updateCardList.mutate({ + cardPublicId, + newListPublicId: member.key, + }) + } + asChild > - - {selectedList?.name} + + {selectedList?.value} - - - -
-
- {lists?.map((list) => ( - - {() => ( -
{ - const newValue = !watch(list.publicId); - setValue(list.publicId, newValue); - - updateCardList.mutate({ - cardPublicId, - newListPublicId: list.publicId, - }); - - handleSubmit(onSubmit); - }} - > - event.stopPropagation()} - {...register(list.publicId)} - checked={watch(list.publicId)} - /> - -
- )} -
- ))} -
-
-
-
-
+ )} ); diff --git a/apps/web/src/views/card/index.tsx b/apps/web/src/views/card/index.tsx index b7f281ce..a7346de9 100644 --- a/apps/web/src/views/card/index.tsx +++ b/apps/web/src/views/card/index.tsx @@ -68,7 +68,8 @@ export default function CardPage() { const formattedLists = board?.lists.map((list) => ({ - ...list, + key: list.publicId, + value: list.name, selected: list.publicId === data?.list?.publicId, })) ?? [];