"use client"; /** * Controlled section editor for a decision-approach chip. Used by both the * custom-rule `decision-approaches` add-method modal and the `final-review` * chip edit modal. Caller owns draft state — Confirm/Save persistence and * `markCreateFlowInteraction` live in the parent. */ import { memo, useCallback } from "react"; import { useMessages } from "../../../../contexts/MessagesContext"; import ModalTextAreaField from "../ModalTextAreaField"; import ApplicableScopeField from "../ApplicableScopeField"; import IncrementerBlock from "../../../../components/controls/IncrementerBlock"; import type { DecisionApproachDetailEntry } from "../../types"; export interface DecisionApproachEditFieldsProps { value: DecisionApproachDetailEntry; onChange: (_next: DecisionApproachDetailEntry) => void; } const CONSENSUS_LEVEL_MIN = 0; const CONSENSUS_LEVEL_MAX = 100; const CONSENSUS_LEVEL_STEP = 5; function DecisionApproachEditFieldsComponent({ value, onChange, }: DecisionApproachEditFieldsProps) { const m = useMessages(); const t = m.create.customRule.decisionApproaches; const patch = useCallback( ( key: K, next: DecisionApproachDetailEntry[K], ) => { onChange({ ...value, [key]: next }); }, [value, onChange], ); return (
patch("corePrinciple", v)} /> patch( "selectedApplicableScope", value.selectedApplicableScope.includes(scope) ? value.selectedApplicableScope.filter((s) => s !== scope) : [...value.selectedApplicableScope, scope], ) } onAddScope={(scope) => patch("applicableScope", [...value.applicableScope, scope]) } /> patch("stepByStepInstructions", v)} /> patch("consensusLevel", next)} formatValue={(v) => `${v}%`} decrementAriaLabel="Decrease consensus level" incrementAriaLabel="Increase consensus level" /> patch("objectionsDeadlocks", v)} />
); } DecisionApproachEditFieldsComponent.displayName = "DecisionApproachEditFields"; export default memo(DecisionApproachEditFieldsComponent);