"use client"; import { FC, useState, useRef } from "react"; import { observer } from "mobx-react"; import { ChevronDown, Plus } from "lucide-react"; // plane imports import { EUserPermissions, EUserPermissionsLevel } from "@plane/constants"; import { useTranslation } from "@plane/i18n"; import { IState, TStateGroups } from "@plane/types"; import { StateGroupIcon } from "@plane/ui"; import { cn } from "@plane/utils"; // components import { StateList, StateCreate } from "@/components/project-states"; // hooks import { useUserPermissions } from "@/hooks/store"; type TGroupItem = { workspaceSlug: string; projectId: string; groupKey: TStateGroups; groupsExpanded: Partial[]; handleGroupCollapse: (groupKey: TStateGroups) => void; handleExpand: (groupKey: TStateGroups) => void; groupedStates: Record; states: IState[]; }; export const GroupItem: FC = observer((props) => { const { workspaceSlug, projectId, groupKey, groupedStates, states, groupsExpanded, handleExpand, handleGroupCollapse, } = props; // refs const dropElementRef = useRef(null); // plane hooks const { t } = useTranslation(); // store hooks const { allowPermissions } = useUserPermissions(); // state const [createState, setCreateState] = useState(false); // derived values const currentStateExpanded = groupsExpanded.includes(groupKey); const isEditable = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT); 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)} />
)}
); });