"use client"; import type { FC } from "react"; import { useState, useRef } from "react"; import { observer } from "mobx-react"; import { ChevronDown, Plus } from "lucide-react"; // plane imports import { EIconSize, STATE_TRACKER_ELEMENTS } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; import { StateGroupIcon } from "@plane/propel/icons"; import type { IState, TStateGroups, TStateOperationsCallbacks } from "@plane/types"; import { cn } from "@plane/utils"; // components import { StateList, StateCreate } from "@/components/project-states"; type TGroupItem = { groupKey: TStateGroups; groupsExpanded: Partial[]; groupedStates: Record; states: IState[]; stateOperationsCallbacks: TStateOperationsCallbacks; isEditable: boolean; shouldTrackEvents: boolean; groupItemClassName?: string; stateItemClassName?: string; handleGroupCollapse: (groupKey: TStateGroups) => void; handleExpand: (groupKey: TStateGroups) => void; }; export const GroupItem: FC = observer((props) => { const { groupKey, groupedStates, states, groupsExpanded, isEditable, stateOperationsCallbacks, shouldTrackEvents, groupItemClassName, stateItemClassName, handleExpand, handleGroupCollapse, } = props; // refs const dropElementRef = useRef(null); // plane hooks const { t } = useTranslation(); // state const [createState, setCreateState] = useState(false); // derived values const currentStateExpanded = groupsExpanded.includes(groupKey); const shouldShowEmptyState = states.length === 0 && currentStateExpanded && !createState; return (
(!currentStateExpanded ? handleExpand(groupKey) : handleGroupCollapse(groupKey))} >
{groupKey}
{shouldShowEmptyState && (
{t("project_settings.states.empty_state.title", { groupKey })}
{isEditable &&
{t("project_settings.states.empty_state.description")}
}
)} {currentStateExpanded && (
)} {isEditable && createState && (
setCreateState(false)} createStateCallback={stateOperationsCallbacks.createState} shouldTrackEvents={shouldTrackEvents} />
)}
); });