// react import React, { useState } from "react"; // headless ui import { Combobox, Dialog, Transition } from "@headlessui/react"; // ui import { Button } from "ui"; // icons import { MagnifyingGlassIcon, RectangleStackIcon } from "@heroicons/react/24/outline"; // types import { IIssue } from "types"; import { classNames } from "constants/common"; import useUser from "lib/hooks/useUser"; type Props = { isOpen: boolean; handleClose: () => void; value?: any; onChange: (...event: any[]) => void; issues: IIssue[]; title?: string; multiple?: boolean; customDisplay?: JSX.Element; }; const IssuesListModal: React.FC = ({ isOpen, handleClose: onClose, value, onChange, issues, title = "Issues", multiple = false, customDisplay, }) => { const [query, setQuery] = useState(""); const [values, setValues] = useState([]); const { activeProject } = useUser(); const handleClose = () => { onClose(); setQuery(""); setValues([]); }; const filteredIssues: IIssue[] = query === "" ? issues ?? [] : issues?.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ?? []; return ( <> setQuery("")} appear>
{multiple ? ( <> { // setValues(val); console.log(val); }} multiple >
{customDisplay}
{filteredIssues.length > 0 && (
  • {query === "" && (

    {title}

    )}
      {filteredIssues.map((issue) => ( classNames( "flex items-center gap-2 cursor-pointer select-none rounded-md px-3 py-2", active ? "bg-gray-900 bg-opacity-5 text-gray-900" : "" ) } > {({ selected }) => ( <> {activeProject?.identifier}-{issue.sequence_id} {" "} {issue.id} )} ))}
  • )}
    {query !== "" && filteredIssues.length === 0 && (
    )}
    ) : (
    {customDisplay}
    {filteredIssues.length > 0 && (
  • {query === "" && (

    {title}

    )}
      {filteredIssues.map((issue) => ( classNames( "flex items-center gap-2 cursor-pointer select-none rounded-md px-3 py-2", active ? "bg-gray-900 bg-opacity-5 text-gray-900" : "" ) } onClick={() => handleClose()} > {({ selected }) => ( <> {activeProject?.identifier}-{issue.sequence_id} {" "} {issue.name} )} ))}
  • )}
    {query !== "" && filteredIssues.length === 0 && (
    )}
    )}
    ); }; export default IssuesListModal;