diff --git a/apps/app/components/command-palette/addAsSubIssue.tsx b/apps/app/components/command-palette/addAsSubIssue.tsx index 11cfcc907..e8c585e45 100644 --- a/apps/app/components/command-palette/addAsSubIssue.tsx +++ b/apps/app/components/command-palette/addAsSubIssue.tsx @@ -22,7 +22,7 @@ import { PROJECT_ISSUES_LIST } from "constants/fetch-keys"; type Props = { isOpen: boolean; setIsOpen: React.Dispatch>; - parentId: string; + parent: IIssue | undefined; }; type FormInput = { @@ -30,7 +30,7 @@ type FormInput = { cycleId: string; }; -const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parentId }) => { +const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parent }) => { const [query, setQuery] = useState(""); const { activeWorkspace, activeProject, issues } = useUser(); @@ -54,7 +54,7 @@ const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parentId }) => { const addAsSubIssue = (issueId: string) => { if (activeWorkspace && activeProject) { issuesServices - .patchIssue(activeWorkspace.slug, activeProject.id, issueId, { parent: parentId }) + .patchIssue(activeWorkspace.slug, activeProject.id, issueId, { parent: parent?.id }) .then((res) => { mutate( PROJECT_ISSUES_LIST(activeWorkspace.slug, activeProject.id), @@ -127,8 +127,9 @@ const AddAsSubIssue: React.FC = ({ isOpen, setIsOpen, parentId }) => {
    {filteredIssues.map((issue) => { if ( - (issue.parent === "" || issue.parent === null) && - issue.id !== parentId + (issue.parent === "" || issue.parent === null) && // issue does not have any other parent + issue.id !== parent?.id && // issue is not itself + issue.id !== parent?.parent // issue is not it's parent ) return ( void; -}; +import { PROJECT_ISSUES_LIST } from "constants/fetch-keys"; +// constants +import { classNames, copyTextToClipboard } from "constants/common"; type FormInput = { issue_ids: string[]; @@ -45,8 +40,6 @@ type FormInput = { }; const CommandPalette: React.FC = () => { - const router = useRouter(); - const [query, setQuery] = useState(""); const [isPaletteOpen, setIsPaletteOpen] = useState(false); @@ -55,7 +48,9 @@ const CommandPalette: React.FC = () => { const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false); const [isCreateCycleModalOpen, setIsCreateCycleModalOpen] = useState(false); - const { activeWorkspace, activeProject, issues, cycles } = useUser(); + const { activeWorkspace, activeProject, issues } = useUser(); + + const router = useRouter(); const { toggleCollapsed } = useTheme(); @@ -67,14 +62,7 @@ const CommandPalette: React.FC = () => { : issues?.results.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ?? []; - const { - register, - formState: { errors, isSubmitting }, - handleSubmit, - control, - reset, - setError, - } = useForm(); + const { register, handleSubmit, reset } = useForm(); const quickActions = [ { @@ -186,37 +174,6 @@ const CommandPalette: React.FC = () => { } }; - const handleAddToCycle: SubmitHandler = (data) => { - if (!data.issue_ids || data.issue_ids.length === 0) { - setToastAlert({ - title: "Error", - type: "error", - message: "Please select atleast one issue", - }); - return; - } - - if (!data.cycleId) { - setToastAlert({ - title: "Error", - type: "error", - message: "Please select a cycle", - }); - return; - } - - if (activeWorkspace && activeProject) { - issuesServices - .bulkAddIssuesToCycle(activeWorkspace.slug, activeProject.id, data.cycleId, data) - .then((res) => { - console.log(res); - }) - .catch((e) => { - console.log(e); - }); - } - }; - useEffect(() => { document.addEventListener("keydown", handleKeyDown); return () => document.removeEventListener("keydown", handleKeyDown); @@ -269,14 +226,7 @@ const CommandPalette: React.FC = () => { >
    - { - // const { url, onClick } = item; - // if (url) router.push(url); - // else if (onClick) onClick(); - // handleCommandPaletteClose(); - // }} - > +
    { {filteredIssues.map((issue) => ( classNames( - "flex cursor-pointer select-none items-center rounded-md px-3 py-2", + "flex items-center justify-between cursor-pointer select-none rounded-md px-3 py-2", active ? "bg-gray-900 bg-opacity-5 text-gray-900" : "" ) } > {({ active }) => ( <> - {/*