import React, { useState } from "react"; import { observer } from "mobx-react-lite"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // component import { SelectMonthModal } from "components/automation"; import { CustomSelect, CustomSearchSelect, ToggleSwitch, StateGroupIcon, DoubleCircleIcon, Loader } from "@plane/ui"; // icons import { ArchiveX } from "lucide-react"; // types import { IProject } from "types"; // fetch keys import { PROJECT_AUTOMATION_MONTHS } from "constants/project"; type Props = { handleChange: (formData: Partial) => Promise; }; export const AutoCloseAutomation: React.FC = observer((props) => { const { handleChange } = props; // states const [monthModal, setmonthModal] = useState(false); const { user: userStore, project: projectStore, projectState: projectStateStore } = useMobxStore(); const userRole = userStore.currentProjectRole; const projectDetails = projectStore.currentProjectDetails; // const stateGroups = projectStateStore.groupedProjectStates ?? undefined; const states = projectStateStore.projectStates; const options = states ?.filter((state) => state.group === "cancelled") .map((state) => ({ value: state.id, query: state.name, content: (
{state.name}
), })); const multipleOptions = (options ?? []).length > 1; const defaultState = states?.find((s) => s.group === "cancelled")?.id || null; const selectedOption = states?.find((s) => s.id === projectDetails?.default_state ?? defaultState); const currentDefaultState = states?.find((s) => s.id === defaultState); const initialValues: Partial = { close_in: 1, default_state: defaultState, }; return ( <> setmonthModal(false)} handleChange={handleChange} />

Auto-close issues

Plane will automatically close issue that haven{"'"}t been completed or cancelled.

projectDetails?.close_in === 0 ? handleChange({ close_in: 1, default_state: defaultState }) : handleChange({ close_in: 0, default_state: null }) } size="sm" disabled={userRole !== 20} />
{projectDetails ? ( projectDetails.close_in !== 0 && (
Auto-close issues that are inactive for
{ handleChange({ close_in: val }); }} input width="w-full" disabled={userRole !== 20} > <> {PROJECT_AUTOMATION_MONTHS.map((month) => ( {month.label} ))}
Auto-close Status
{selectedOption ? ( ) : currentDefaultState ? ( ) : ( )} {selectedOption?.name ? selectedOption.name : currentDefaultState?.name ?? State}
} onChange={(val: string) => { handleChange({ default_state: val }); }} options={options} disabled={!multipleOptions} width="w-full" input />
) ) : ( )} ); });