diff --git a/apps/app/components/core/multi-level-select.tsx b/apps/app/components/core/multi-level-select.tsx index db74f8bd2..68a76ae91 100644 --- a/apps/app/components/core/multi-level-select.tsx +++ b/apps/app/components/core/multi-level-select.tsx @@ -20,10 +20,11 @@ type TMultipleSelectProps = { selected: TSelectOption | null; setSelected: (value: any) => void; label: string; + direction?: "left" | "right"; }; -export const MultiSelect: React.FC = (props) => { - const { options, selected, setSelected, label } = props; +export const MultiLevelSelect: React.FC = (props) => { + const { options, selected, setSelected, label, direction = "right" } = props; const [openChildFor, setOpenChildFor] = useState(null); @@ -42,7 +43,7 @@ export const MultiSelect: React.FC = (props) => {
setOpenChildFor(null)} - className="relative w-full cursor-default rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 sm:text-sm" + className="relative w-full cursor-default rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md sm:text-sm" > {selected?.label ?? label} @@ -58,35 +59,41 @@ export const MultiSelect: React.FC = (props) => { > {options.map((option) => ( - `relative cursor-default select-none py-2 pl-10 pr-4 ${ - active ? "bg-amber-100 text-amber-900" : "text-gray-900" - }` + className={ + "relative cursor-default select-none py-2 pl-10 pr-4 hover:bg-gray-100 hover:text-gray-900" } onClick={(e: any) => { if (option.children !== null) { e.preventDefault(); setOpenChildFor(option); } + if (option.id === openChildFor?.id) { + e.preventDefault(); + setOpenChildFor(null); + } }} value={option} > {({ selected }) => ( <> {openChildFor?.id === option.id && ( -
+
{option.children?.map((child) => ( - `relative cursor-default select-none py-2 pl-10 pr-4 ${ - active ? "bg-amber-100 text-amber-900" : "text-gray-900" - }` + className={ + "relative cursor-default select-none py-2 pl-10 pr-4 hover:bg-gray-100 hover:text-gray-900" } as="div" value={child} @@ -101,7 +108,7 @@ export const MultiSelect: React.FC = (props) => { {child.label} {selected ? ( - + ) : null} @@ -110,7 +117,13 @@ export const MultiSelect: React.FC = (props) => { ))} -
+
)} = (props) => { {option.label} {selected ? ( - + ) : null}