// 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; }; const IssuesListModal: React.FC = ({ isOpen, handleClose: onClose, value, onChange, issues, title = "Issues", multiple = false, }) => { 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>
{ if (multiple) setValues(val); else onChange(val); }} // multiple={multiple} >
{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={() => { if (!multiple) handleClose(); }} > {({ selected }) => ( <> {multiple ? ( ) : null} {activeProject?.identifier}-{issue.sequence_id} {" "} {issue.name} )} ))}
  • )}
    {query !== "" && filteredIssues.length === 0 && (
    )}
    {multiple ? (
    ) : null}
    ); }; export default IssuesListModal;