"use client"; /** * Controlled section editor for a conflict-management chip. Used by both the * custom-rule `conflict-management` add-method modal and the `final-review` * chip edit modal. Caller owns draft state and persistence. */ import { memo, useCallback } from "react"; import { useMessages } from "../../../../contexts/MessagesContext"; import ModalTextAreaField from "../ModalTextAreaField"; import ApplicableScopeField from "../ApplicableScopeField"; import type { ConflictManagementDetailEntry } from "../../types"; export interface ConflictManagementEditFieldsProps { value: ConflictManagementDetailEntry; onChange: (_next: ConflictManagementDetailEntry) => void; } function ConflictManagementEditFieldsComponent({ value, onChange, }: ConflictManagementEditFieldsProps) { const m = useMessages(); const t = m.create.customRule.conflictManagement; const patch = useCallback( ( key: K, next: ConflictManagementDetailEntry[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("processProtocol", v)} /> patch("restorationFallbacks", v)} />
); } ConflictManagementEditFieldsComponent.displayName = "ConflictManagementEditFields"; export default memo(ConflictManagementEditFieldsComponent);