Show our own save-email error, and open review cards as the deck row view.

A bad address was stopped by the browser bubble before the designed line could appear. Final review opened every part of a method card at once instead of the three-row policy the decks use.
This commit is contained in:
adilallo committed 2026-11-11 10:47:40 -07:00
1 parent 0efc907633
commit 7336cba6f5
13 files changed
+274 -685

No files matched your search

@@ -966,6 +966,7 @@ function CreateFlowLayoutContent({
<form
id={CREATE_FLOW_COMMUNITY_SAVE_FORM_ID}
className="hidden"
noValidate
onSubmit={(e) => {
e.preventDefault();
markAttempted();
@@ -1052,6 +1053,7 @@ function CreateFlowLayoutContent({
<Button
type="submit"
form={CREATE_FLOW_COMMUNITY_SAVE_FORM_ID}
formNoValidate
buttonType="filled"
palette="default"
size="xsmall"
@@ -5,8 +5,7 @@
* (facet screens + final-review chip edit). When `onBlocksChange` is omitted,
* blocks render read-only (disabled controls).
*
* Layout matches preset method editors ({@link CommunicationMethodEditFields},
* {@link DecisionApproachEditFields}): {@link ModalTextAreaField},
* Layout matches the deck policy editors: {@link ModalTextAreaField},
* {@link ApplicableScopeField} chip rows, {@link IncrementerBlock}.
*/
@@ -2,11 +2,12 @@
/**
* Final-review chip modal: **Core values** use {@link ValueDialog} (Deselect +
* Cancel + Save; kebab Customize / Duplicate under the cap). **Method** facets
* keep `Create` with kebab Duplicate/Remove plus a footer **Remove** when the
* chip is already in the selection. Values and method chips also offer
* **Customize**, which opens {@link CustomMethodCardWizard} prefilled from the
* chip. Fields are editable on open; Save persists body edits without renaming.
* Cancel + Save; kebab Customize / Duplicate under the cap). **Method** chips
* use {@link MethodCardPolicyDialog}, the same routing card as the decks: a
* row per part, then that part's editor. Footer **Deselect** when the chip is
* already selected; Save stays off until the draft changes. Values and method
* chips also offer **Customize**, which opens {@link CustomMethodCardWizard}
* prefilled from the chip.
*
* Template-only chips without an `overrideKey` never mount this component; they
* use {@link TemplateChipDetailModal} from the parent.
@@ -15,16 +16,15 @@
*/
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import Create from "../../../components/modals/Create";
import ContentLockup from "../../../components/type/ContentLockup";
import { useMessages, useTranslation } from "../../../contexts/MessagesContext";
import {
CommunicationMethodEditFields,
ConflictManagementEditFields,
DecisionApproachEditFields,
MembershipMethodEditFields,
} from "./methodEditFields";
import { useMessages } from "../../../contexts/MessagesContext";
import { ValueDialog } from "./ValueDialog";
import { MethodCardPolicyDialog } from "./MethodCardPolicyDialog";
import {
useCommunicationPolicySteps,
useConflictPolicySteps,
useDecisionApproachPolicySteps,
useMembershipPolicySteps,
} from "./methodCardPolicySteps";
import CustomMethodCardModalBody from "./CustomMethodCardModalBody";
import { buildCustomRuleModalKebabMenu } from "./customRuleModalKebabMenu";
import { useDiscardCustomizeConfirm } from "../hooks/useDiscardCustomizeConfirm";
@@ -187,9 +187,6 @@ export function FinalReviewChipEditModal({
const tDa = cr.decisionApproaches;
const tCm = cr.conflictManagement;
const modalKebabMenu = cr.modalKebabMenu;
const tModal = useTranslation(
"create.reviewAndComplete.finalReview.chipEditModal",
);
const { confirmDiscard, confirmDialog } = useDiscardCustomizeConfirm();
const [draft, setDraft] = useState<Draft | null>(null);
@@ -831,6 +828,7 @@ export function FinalReviewChipEditModal({
const facet = CUSTOM_RULE_FACET_BY_GROUP.get(target.groupKey)!;
const pendingId = target.overrideKey;
const sel = [...facet.selectionIds(state)];
if (sel.includes(pendingId) && methodCustomizeSaveDisabled) return;
onInteract?.();
const persistWizardBlocks = draftFieldBlocks !== null;
@@ -906,6 +904,7 @@ export function FinalReviewChipEditModal({
draft,
draftFieldBlocks,
finalizeModalClose,
methodCustomizeSaveDisabled,
onInteract,
onSave,
replaceState,
@@ -1044,44 +1043,48 @@ export function FinalReviewChipEditModal({
],
);
const handleNext = useCallback(() => {
if (!target || !draft) return;
if (target.groupKey === "coreValues") {
handleCoreSave();
} else {
handleMethodPrimary();
}
}, [draft, handleCoreSave, handleMethodPrimary, target]);
const nextButtonText = useMemo(() => {
if (!target) return tModal("saveButton");
if (target.groupKey === "coreValues") {
return tModal("saveButton");
}
if (!isChipInSelection) {
return addPrimaryLabelForMethodFacet(target.groupKey, cr);
}
return tModal("saveButton");
}, [cr, isChipInSelection, target, tModal]);
const headerContent = useMemo(() => {
if (!target) return undefined;
return (
<div className="bg-[var(--color-surface-default-primary)] px-[24px] py-[12px] shrink-0">
<ContentLockup
title={target.chipLabel}
description={subtitle}
variant="modal"
alignment="left"
/>
</div>
);
}, [subtitle, target]);
const showFooterRemove =
target != null &&
target.groupKey !== "coreValues" &&
isChipInSelection;
const communicationSteps = useCommunicationPolicySteps(
draft?.groupKey === "communication"
? draft.value
: emptyCommunicationDetails(),
(value) => setDraft({ groupKey: "communication", value }),
target?.groupKey === "communication"
? communicationPresetFor(target.overrideKey)
: undefined,
);
const membershipSteps = useMembershipPolicySteps(
draft?.groupKey === "membership" ? draft.value : emptyMembershipDetails(),
(value) => setDraft({ groupKey: "membership", value }),
target?.groupKey === "membership"
? membershipPresetFor(target.overrideKey)
: undefined,
);
const decisionSteps = useDecisionApproachPolicySteps(
draft?.groupKey === "decisionApproaches"
? draft.value
: emptyDecisionApproachTextFields(decisionApproachPresetFor("")),
(value) => setDraft({ groupKey: "decisionApproaches", value }),
target?.groupKey === "decisionApproaches"
? decisionApproachPresetFor(target.overrideKey)
: undefined,
);
const conflictSteps = useConflictPolicySteps(
draft?.groupKey === "conflictManagement"
? draft.value
: emptyConflictManagementDetails(),
(value) => setDraft({ groupKey: "conflictManagement", value }),
target?.groupKey === "conflictManagement"
? conflictManagementPresetFor(target.overrideKey)
: undefined,
);
const methodSteps =
draft?.groupKey === "membership"
? membershipSteps
: draft?.groupKey === "decisionApproaches"
? decisionSteps
: draft?.groupKey === "conflictManagement"
? conflictSteps
: communicationSteps;
const isCoreValuesTarget = target?.groupKey === "coreValues";
const coreDraftValue =
@@ -1103,7 +1106,7 @@ export function FinalReviewChipEditModal({
onClose={() => {
void handleModalClose();
}}
onConfirm={handleNext}
onConfirm={handleCoreSave}
onDeselect={handleRemoveCoreValueFromModal}
nextButtonDisabled={coreCustomizeSaveDisabled}
kebabTriggerAriaLabel={modalKebabMenu.triggerAriaLabel}
@@ -1131,151 +1134,52 @@ export function FinalReviewChipEditModal({
/>
) : undefined}
</ValueDialog>
<Create
isOpen={
isOpen && !addCustomWizardOpen && !isCoreValuesTarget
}
onClose={handleModalClose}
onBack={handleModalClose}
showBackButton={!showFooterRemove}
showRemoveButton={showFooterRemove}
onRemove={
target?.groupKey === "coreValues"
? handleRemoveCoreValueFromModal
: handleRemoveSelectedFromModal
}
backdropVariant="blurredYellow"
headerContent={headerContent}
showNextButton={true}
onNext={handleNext}
nextButtonText={nextButtonText}
nextButtonDisabled={
target?.groupKey === "coreValues"
? coreCustomizeSaveDisabled
: methodCustomizeSaveDisabled
}
kebabTriggerAriaLabel={modalKebabMenu.triggerAriaLabel}
kebabMenuAriaLabel={modalKebabMenu.menuAriaLabel}
kebabMenuItems={
target && kebabMenuItems.length > 0 ? kebabMenuItems : undefined
}
ariaLabel={target?.chipLabel || "Edit chip details"}
>
<div className="flex flex-col gap-[var(--space-600)] pb-2">
{draft?.groupKey === "communication" &&
target &&
(modalUsesWizardFieldBlocksBody ? (
<CustomMethodCardModalBody
cardId={target.overrideKey}
blocksById={state.customMethodCardFieldBlocksById}
blocksOverride={
draftFieldBlocks !== null ? draftFieldBlocks : undefined
<MethodCardPolicyDialog
isOpen={isOpen && !addCustomWizardOpen && !isCoreValuesTarget}
cardLabel={target?.chipLabel ?? ""}
description={subtitle}
editing={isChipInSelection}
steps={methodSteps}
onClose={() => {
void handleModalClose();
}}
onConfirm={handleMethodPrimary}
onDeselect={
isChipInSelection
? () => {
void handleRemoveSelectedFromModal();
}
policyMeta={
state.customMethodCardMetaById?.[target.overrideKey]
}
showPolicyContentLockupWhenNoBlocks={false}
onFieldBlocksChange={
draftFieldBlocks === null
? undefined
: handleWizardFieldBlocksChange
}
/>
) : (
<CommunicationMethodEditFields
value={draft.value}
onChange={(value) =>
setDraft({ groupKey: "communication", value })
}
generateDraft={communicationPresetFor(target.overrideKey)}
/>
))}
{draft?.groupKey === "membership" &&
target &&
(modalUsesWizardFieldBlocksBody ? (
<CustomMethodCardModalBody
cardId={target.overrideKey}
blocksById={state.customMethodCardFieldBlocksById}
blocksOverride={
draftFieldBlocks !== null ? draftFieldBlocks : undefined
}
policyMeta={
state.customMethodCardMetaById?.[target.overrideKey]
}
showPolicyContentLockupWhenNoBlocks={false}
onFieldBlocksChange={
draftFieldBlocks === null
? undefined
: handleWizardFieldBlocksChange
}
/>
) : (
<MembershipMethodEditFields
value={draft.value}
onChange={(value) =>
setDraft({ groupKey: "membership", value })
}
generateDraft={membershipPresetFor(target.overrideKey)}
/>
))}
{draft?.groupKey === "decisionApproaches" &&
target &&
(modalUsesWizardFieldBlocksBody ? (
<CustomMethodCardModalBody
cardId={target.overrideKey}
blocksById={state.customMethodCardFieldBlocksById}
blocksOverride={
draftFieldBlocks !== null ? draftFieldBlocks : undefined
}
policyMeta={
state.customMethodCardMetaById?.[target.overrideKey]
}
showPolicyContentLockupWhenNoBlocks={false}
onFieldBlocksChange={
draftFieldBlocks === null
? undefined
: handleWizardFieldBlocksChange
}
/>
) : (
<DecisionApproachEditFields
value={draft.value}
onChange={(value) =>
setDraft({ groupKey: "decisionApproaches", value })
}
generateDraft={decisionApproachPresetFor(target.overrideKey)}
/>
))}
{draft?.groupKey === "conflictManagement" &&
target &&
(modalUsesWizardFieldBlocksBody ? (
<CustomMethodCardModalBody
cardId={target.overrideKey}
blocksById={state.customMethodCardFieldBlocksById}
blocksOverride={
draftFieldBlocks !== null ? draftFieldBlocks : undefined
}
policyMeta={
state.customMethodCardMetaById?.[target.overrideKey]
}
showPolicyContentLockupWhenNoBlocks={false}
onFieldBlocksChange={
draftFieldBlocks === null
? undefined
: handleWizardFieldBlocksChange
}
/>
) : (
<ConflictManagementEditFields
value={draft.value}
onChange={(value) =>
setDraft({ groupKey: "conflictManagement", value })
}
generateDraft={conflictManagementPresetFor(target.overrideKey)}
/>
))}
</div>
</Create>
: undefined
}
confirmDisabled={isChipInSelection && methodCustomizeSaveDisabled}
kebabTriggerAriaLabel={modalKebabMenu.triggerAriaLabel}
kebabMenuAriaLabel={modalKebabMenu.menuAriaLabel}
kebabMenuItems={
target && !isCoreValuesTarget && kebabMenuItems.length > 0
? kebabMenuItems
: undefined
}
ariaLabel={target?.chipLabel || "Edit chip details"}
>
{modalUsesWizardFieldBlocksBody &&
target &&
isMethodFacetGroup(target.groupKey) ? (
<CustomMethodCardModalBody
cardId={target.overrideKey}
blocksById={state.customMethodCardFieldBlocksById}
blocksOverride={
draftFieldBlocks !== null ? draftFieldBlocks : undefined
}
policyMeta={state.customMethodCardMetaById?.[target.overrideKey]}
showPolicyContentLockupWhenNoBlocks={false}
onFieldBlocksChange={
draftFieldBlocks === null
? undefined
: handleWizardFieldBlocksChange
}
/>
) : null}
</MethodCardPolicyDialog>
<CustomMethodCardWizard
isOpen={addCustomWizardOpen}
onClose={handleCloseAddWizard}
@@ -1336,22 +1240,6 @@ function facetSeedSignature(
}
}
function addPrimaryLabelForMethodFacet(
groupKey: MethodFacetGroupKey,
cr: ReturnType<typeof useMessages>["create"]["customRule"],
): string {
switch (groupKey) {
case "communication":
return cr.communication.addPlatform.nextButtonText;
case "membership":
return cr.membership.addPlatform.nextButtonText;
case "decisionApproaches":
return cr.decisionApproaches.addApproach.nextButtonText;
case "conflictManagement":
return cr.conflictManagement.addApproach.nextButtonText;
}
}
function seedDraftForTarget(
target: FinalReviewChipEditTarget,
state: CreateFlowState,
@@ -36,6 +36,11 @@ export type MethodCardPolicyDialogProps = {
ariaLabel?: string;
/** Customized field-blocks body. Replaces the routing steps. */
children?: ReactNode;
/**
* Disables the routing-view primary action (Add to Rule / Save).
* A step's own Save stays enabled so the reader can return to the rows.
*/
confirmDisabled?: boolean;
};
function MethodCardPolicyDialogComponent({
@@ -52,6 +57,7 @@ function MethodCardPolicyDialogComponent({
kebabMenuItems,
ariaLabel,
children,
confirmDisabled = false,
}: MethodCardPolicyDialogProps) {
const m = useMessages();
const t = m.create.customRule.cardDialog;
@@ -104,6 +110,7 @@ function MethodCardPolicyDialogComponent({
onRemove={onDeselect}
cancelButtonText={t.cancel}
nextButtonText={primaryLabel}
nextButtonDisabled={activeStepId == null && confirmDisabled}
removeButtonText={t.deselect}
stepper={false}
backdropVariant="blurredYellow"
@@ -1,73 +0,0 @@
"use client";
/**
* Controlled section editor for a communication-method chip. Used by both
* the custom-rule `communication-methods` add-method modal and the
* `final-review` chip edit modal — caller owns draft state and decides when
* to persist or discard.
*/
import { memo, useCallback } from "react";
import { useMessages } from "../../../../contexts/MessagesContext";
import ModalTextAreaField from "../ModalTextAreaField";
import type { CommunicationMethodDetailEntry } from "../../types";
export interface CommunicationMethodEditFieldsProps {
value: CommunicationMethodDetailEntry;
onChange: (_next: CommunicationMethodDetailEntry) => void;
/** When true, fields are not editable (view mode). */
readOnly?: boolean;
/** Catalog copy inserted by Generate draft. */
generateDraft?: CommunicationMethodDetailEntry;
}
const FIELDS: ReadonlyArray<keyof CommunicationMethodDetailEntry> = [
"corePrinciple",
"logisticsAdmin",
"codeOfConduct",
];
function CommunicationMethodEditFieldsComponent({
value,
onChange,
readOnly = false,
generateDraft,
}: CommunicationMethodEditFieldsProps) {
const m = useMessages();
const t = m.create.customRule.communication;
const draftField = m.create.draftField;
const patch = useCallback(
<K extends keyof CommunicationMethodDetailEntry>(
key: K,
next: CommunicationMethodDetailEntry[K],
) => {
onChange({ ...value, [key]: next });
},
[value, onChange],
);
return (
<div className="flex flex-col gap-6">
{FIELDS.map((field) => (
<ModalTextAreaField
key={field}
label={t.sectionHeadings[field]}
rows={6}
value={value[field]}
onChange={(v) => patch(field, v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.[field]}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
))}
</div>
);
}
CommunicationMethodEditFieldsComponent.displayName =
"CommunicationMethodEditFields";
export default memo(CommunicationMethodEditFieldsComponent);
@@ -1,121 +0,0 @@
"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 { formatConflictApplicableScopeForTextarea } from "../../../../../lib/create/ruleSectionsFromMethodSelections";
import { useMessages } from "../../../../contexts/MessagesContext";
import ModalTextAreaField from "../ModalTextAreaField";
import type { ConflictManagementDetailEntry } from "../../types";
function conflictScopeTextareaValue(value: ConflictManagementDetailEntry): string {
return formatConflictApplicableScopeForTextarea(
value.selectedApplicableScope,
value.applicableScope,
);
}
function conflictDetailWithScopeTextarea(
value: ConflictManagementDetailEntry,
text: string,
): ConflictManagementDetailEntry {
const lines = text
.split("\n")
.map((s) => s.trim())
.filter((s) => s.length > 0);
return {
...value,
applicableScope: lines,
selectedApplicableScope: [...lines],
};
}
export interface ConflictManagementEditFieldsProps {
value: ConflictManagementDetailEntry;
onChange: (_next: ConflictManagementDetailEntry) => void;
readOnly?: boolean;
/** Catalog copy inserted by Generate draft. */
generateDraft?: ConflictManagementDetailEntry;
}
function ConflictManagementEditFieldsComponent({
value,
onChange,
readOnly = false,
generateDraft,
}: ConflictManagementEditFieldsProps) {
const m = useMessages();
const t = m.create.customRule.conflictManagement;
const draftField = m.create.draftField;
const patch = useCallback(
<K extends keyof ConflictManagementDetailEntry>(
key: K,
next: ConflictManagementDetailEntry[K],
) => {
onChange({ ...value, [key]: next });
},
[value, onChange],
);
return (
<div className="flex flex-col gap-6">
<ModalTextAreaField
label={t.sectionHeadings.corePrinciple}
value={value.corePrinciple}
onChange={(v) => patch("corePrinciple", v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.corePrinciple}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
<ModalTextAreaField
label={t.sectionHeadings.applicableScope}
value={conflictScopeTextareaValue(value)}
placeholder={t.applicableScopePlaceholder}
onChange={(v) => onChange(conflictDetailWithScopeTextarea(value, v))}
rows={4}
disabled={readOnly}
generateDraftText={
generateDraft && generateDraft.applicableScope.length > 0
? generateDraft.applicableScope.join("\n")
: generateDraft
? conflictScopeTextareaValue(generateDraft)
: undefined
}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
<ModalTextAreaField
label={t.sectionHeadings.processProtocol}
value={value.processProtocol}
onChange={(v) => patch("processProtocol", v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.processProtocol}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
<ModalTextAreaField
label={t.sectionHeadings.restorationFallbacks}
value={value.restorationFallbacks}
onChange={(v) => patch("restorationFallbacks", v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.restorationFallbacks}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
</div>
);
}
ConflictManagementEditFieldsComponent.displayName =
"ConflictManagementEditFields";
export default memo(ConflictManagementEditFieldsComponent);
@@ -1,137 +0,0 @@
"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, useMemo } 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";
import { withDecisionApproachKeyResourceScopes } from "../../../../../lib/create/decisionApproachKeyResources";
export interface DecisionApproachEditFieldsProps {
value: DecisionApproachDetailEntry;
onChange: (_next: DecisionApproachDetailEntry) => void;
readOnly?: boolean;
/** Catalog copy inserted by Generate draft on text fields. */
generateDraft?: DecisionApproachDetailEntry;
}
const CONSENSUS_LEVEL_MIN = 0;
const CONSENSUS_LEVEL_MAX = 100;
const CONSENSUS_LEVEL_STEP = 5;
function DecisionApproachEditFieldsComponent({
value,
onChange,
readOnly = false,
generateDraft,
}: DecisionApproachEditFieldsProps) {
const m = useMessages();
const t = m.create.customRule.decisionApproaches;
const draftField = m.create.draftField;
const scopes = useMemo(
() => withDecisionApproachKeyResourceScopes(value.applicableScope),
[value.applicableScope],
);
const patch = useCallback(
<K extends keyof DecisionApproachDetailEntry>(
key: K,
next: DecisionApproachDetailEntry[K],
) => {
onChange({ ...value, [key]: next });
},
[value, onChange],
);
return (
<div className="flex flex-col gap-6">
<ModalTextAreaField
label={t.sectionHeadings.corePrinciple}
value={value.corePrinciple}
onChange={(v) => patch("corePrinciple", v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.corePrinciple}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
<ApplicableScopeField
label={t.sectionHeadings.applicableScope}
addLabel={t.scopeAddButtonLabel}
scopes={scopes}
selectedScopes={value.selectedApplicableScope}
readOnly={readOnly}
onToggleScope={(scope) =>
patch(
"selectedApplicableScope",
value.selectedApplicableScope.includes(scope)
? value.selectedApplicableScope.filter((s) => s !== scope)
: [...value.selectedApplicableScope, scope],
)
}
onAddScope={(scope) =>
patch("applicableScope", [...value.applicableScope, scope])
}
/>
<ModalTextAreaField
label={t.sectionHeadings.stepByStepInstructions}
value={value.stepByStepInstructions}
onChange={(v) => patch("stepByStepInstructions", v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.stepByStepInstructions}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
{value.consensusLevel === undefined ? (
<ModalTextAreaField
label={t.sectionHeadings.consensusLevel}
value={t.consensusLevelDisplay.supermajorityShare}
onChange={() => {}}
disabled
rows={1}
/>
) : (
<IncrementerBlock
label={t.sectionHeadings.consensusLevel}
helpIcon={false}
value={value.consensusLevel}
min={CONSENSUS_LEVEL_MIN}
max={CONSENSUS_LEVEL_MAX}
step={CONSENSUS_LEVEL_STEP}
onChange={(next) => patch("consensusLevel", next)}
formatValue={(v) =>
v === 0 ? t.consensusLevelDisplay.noSetShare : `${v}%`
}
decrementAriaLabel="Decrease consensus level"
incrementAriaLabel="Increase consensus level"
disabled={readOnly}
/>
)}
<ModalTextAreaField
label={t.sectionHeadings.objectionsDeadlocks}
value={value.objectionsDeadlocks}
onChange={(v) => patch("objectionsDeadlocks", v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.objectionsDeadlocks}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
</div>
);
}
DecisionApproachEditFieldsComponent.displayName =
"DecisionApproachEditFields";
export default memo(DecisionApproachEditFieldsComponent);
@@ -1,72 +0,0 @@
"use client";
/**
* Controlled section editor for a membership-method chip. Used by both the
* custom-rule `membership-methods` add-method modal and the `final-review`
* chip edit modal — caller owns draft state and decides when to persist or
* discard.
*/
import { memo, useCallback } from "react";
import { useMessages } from "../../../../contexts/MessagesContext";
import ModalTextAreaField from "../ModalTextAreaField";
import type { MembershipMethodDetailEntry } from "../../types";
export interface MembershipMethodEditFieldsProps {
value: MembershipMethodDetailEntry;
onChange: (_next: MembershipMethodDetailEntry) => void;
readOnly?: boolean;
/** Catalog copy inserted by Generate draft. */
generateDraft?: MembershipMethodDetailEntry;
}
const FIELDS: ReadonlyArray<keyof MembershipMethodDetailEntry> = [
"eligibility",
"joiningProcess",
"expectations",
];
function MembershipMethodEditFieldsComponent({
value,
onChange,
readOnly = false,
generateDraft,
}: MembershipMethodEditFieldsProps) {
const m = useMessages();
const t = m.create.customRule.membership;
const draftField = m.create.draftField;
const patch = useCallback(
<K extends keyof MembershipMethodDetailEntry>(
key: K,
next: MembershipMethodDetailEntry[K],
) => {
onChange({ ...value, [key]: next });
},
[value, onChange],
);
return (
<div className="flex flex-col gap-6">
{FIELDS.map((field) => (
<ModalTextAreaField
key={field}
label={t.sectionHeadings[field]}
rows={6}
value={value[field]}
onChange={(v) => patch(field, v)}
disabled={readOnly}
placeholder={draftField.placeholder}
generateDraftText={generateDraft?.[field]}
generateDraftLabel={draftField.generateDraft}
generateDraftHint={draftField.generateDraftHint}
/>
))}
</div>
);
}
MembershipMethodEditFieldsComponent.displayName =
"MembershipMethodEditFields";
export default memo(MembershipMethodEditFieldsComponent);
@@ -1,11 +0,0 @@
export { default as CommunicationMethodEditFields } from "./CommunicationMethodEditFields";
export type { CommunicationMethodEditFieldsProps } from "./CommunicationMethodEditFields";
export { default as MembershipMethodEditFields } from "./MembershipMethodEditFields";
export type { MembershipMethodEditFieldsProps } from "./MembershipMethodEditFields";
export { default as DecisionApproachEditFields } from "./DecisionApproachEditFields";
export type { DecisionApproachEditFieldsProps } from "./DecisionApproachEditFields";
export { default as ConflictManagementEditFields } from "./ConflictManagementEditFields";
export type { ConflictManagementEditFieldsProps } from "./ConflictManagementEditFields";
@@ -86,12 +86,13 @@ export function FinalReviewScreen({
/**
* Two modals coexist on this screen:
*
* - {@link FinalReviewChipEditModal} — core values + method chips: footer
* **Remove** when the chip is already selected, plus kebab **Remove**;
* - {@link FinalReviewChipEditModal} — core values use the value card;
* method chips use the deck's routing card (a row per part). Footer
* **Deselect** when the chip is already selected, plus kebab **Remove**;
* values also offer Duplicate under the five-chip cap; method chips
* offer Customize (prefilled custom-policy wizard). Fields are editable on
* open. Save writes `{group}DetailsById` and field blocks; wizard Finalize
* also writes `customMethodCardMetaById`.
* offer Customize (prefilled custom-policy wizard). Save writes
* `{group}DetailsById` and field blocks; wizard Finalize also writes
* `customMethodCardMetaById`.
* - {@link TemplateChipDetailModal} — read-only fallback for chips we
* can't map to an override key (e.g. template body entries on the
* "Use without changes" path where no preset matches the title).