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:
1 parent
0efc907633
commit
7336cba6f5
13 files changed
+274
-685
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user