import { useState } from "react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; // hooks // ui import { Pencil, X, ArrowDown, ArrowUp } from "lucide-react"; import { IState } from "@plane/types"; import { Tooltip, StateGroupIcon } from "@plane/ui"; // icons // helpers import { addSpaceIfCamelCase } from "@/helpers/string.helper"; import { useEventTracker, useProjectState } from "@/hooks/store"; import { usePlatformOS } from "@/hooks/use-platform-os"; // types type Props = { index: number; state: IState; statesList: IState[]; handleEditState: () => void; handleDeleteState: () => void; }; export const StatesListItem: React.FC = observer((props) => { const { index, state, statesList, handleEditState, handleDeleteState } = props; // states const [isSubmitting, setIsSubmitting] = useState(false); // router const router = useRouter(); const { workspaceSlug, projectId } = router.query; // store hooks const { setTrackElement } = useEventTracker(); const { markStateAsDefault, moveStatePosition } = useProjectState(); const { isMobile } = usePlatformOS(); // derived values const groupStates = statesList.filter((s) => s.group === state.group); const groupLength = groupStates.length; const handleMakeDefault = () => { if (!workspaceSlug || !projectId) return; setIsSubmitting(true); markStateAsDefault(workspaceSlug.toString(), projectId.toString(), state.id).finally(() => { setIsSubmitting(false); }); }; const handleMove = (state: IState, direction: "up" | "down") => { if (!workspaceSlug || !projectId) return; moveStatePosition(workspaceSlug.toString(), projectId.toString(), state.id, direction, index); }; return (
{addSpaceIfCamelCase(state.name)}

{state.description}

{index !== 0 && ( )} {!(index === groupLength - 1) && ( )}
{state.default ? ( Default ) : ( )}
); });