From fc845d830868c5ad7cf8035dd90b698540df48a3 Mon Sep 17 00:00:00 2001 From: adilallo <39313955+adilallo@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:29:16 -0600 Subject: [PATCH] Edit flow configured --- app/(app)/create/CreateFlowLayoutClient.tsx | 64 ++++++++-- app/(app)/create/SignedInDraftHydration.tsx | 6 + .../create/context/CreateFlowContext.tsx | 16 +++ .../create/hooks/useCreateFlowNavigation.ts | 23 +++- .../create/hooks/useMethodCardDeckOrdering.ts | 109 ++++++++++++++++++ .../card/CommunicationMethodsScreen.tsx | 38 +----- .../screens/card/ConflictManagementScreen.tsx | 38 +----- .../screens/card/MembershipMethodsScreen.tsx | 38 +----- .../screens/review/FinalReviewScreen.tsx | 40 ++++++- .../right-rail/DecisionApproachesScreen.tsx | 37 +----- app/(app)/create/types.ts | 23 ++++ .../utils/customRuleConfirmFooterSteps.ts | 27 ++++- .../utils/facetGroupToCreateFlowStep.ts | 19 +++ app/(app)/create/utils/flowSteps.ts | 14 +++ .../profile/_components/ProfilePage.view.tsx | 5 + app/api/rules/route.ts | 3 +- app/components/cards/Rule/Rule.container.tsx | 2 + app/components/cards/Rule/Rule.types.ts | 9 ++ app/components/cards/Rule/Rule.view.tsx | 19 ++- .../GovernanceTemplateGrid.tsx | 1 + app/components/utility/Tag/Tag.container.tsx | 1 + app/components/utility/Tag/Tag.types.ts | 8 +- app/components/utility/Tag/Tag.view.tsx | 17 ++- lib/create/api.ts | 4 +- lib/create/lastPublishedRule.ts | 3 +- lib/create/methodCardDisplayOrder.ts | 67 +++++++++++ lib/server/publishedRules.ts | 5 +- lib/server/validation/createFlowSchemas.ts | 9 ++ lib/templates/governanceTemplateCatalog.ts | 6 + lib/templates/templateGridPresentation.ts | 13 ++- messages/en/components/ruleCard.json | 3 +- messages/en/pages/profile.json | 1 + stories/cards/Rule.stories.js | 18 +++ stories/utility/Tag.stories.js | 10 +- tests/contexts/CreateFlowContext.test.tsx | 22 +++- tests/unit/Rule.test.jsx | 12 ++ tests/unit/facetGroupToCreateFlowStep.test.ts | 18 +++ tests/unit/flowSteps.test.ts | 18 +++ tests/unit/methodCardDisplayOrder.test.ts | 80 +++++++++++++ 39 files changed, 681 insertions(+), 165 deletions(-) create mode 100644 app/(app)/create/hooks/useMethodCardDeckOrdering.ts create mode 100644 app/(app)/create/utils/facetGroupToCreateFlowStep.ts create mode 100644 lib/create/methodCardDisplayOrder.ts create mode 100644 tests/unit/facetGroupToCreateFlowStep.test.ts create mode 100644 tests/unit/methodCardDisplayOrder.test.ts diff --git a/app/(app)/create/CreateFlowLayoutClient.tsx b/app/(app)/create/CreateFlowLayoutClient.tsx index ad67618..a326c4e 100644 --- a/app/(app)/create/CreateFlowLayoutClient.tsx +++ b/app/(app)/create/CreateFlowLayoutClient.tsx @@ -7,7 +7,7 @@ import { useState, type ReactNode, } from "react"; -import { usePathname, useRouter } from "next/navigation"; +import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { CreateFlowProvider, useCreateFlow } from "./context/CreateFlowContext"; import { useCreateFlowNavigation } from "./hooks/useCreateFlowNavigation"; import { useCreateFlowExit } from "./hooks/useCreateFlowExit"; @@ -15,7 +15,7 @@ import { useCreateFlowFinalize } from "./hooks/useCreateFlowFinalize"; import { useTemplateReviewActions } from "./hooks/useTemplateReviewActions"; import CreateFlowFooter from "../../components/navigation/CreateFlowFooter"; import CreateFlowTopNav from "../../components/navigation/CreateFlowTopNav"; -import { getNextStep, getStepIndex } from "./utils/flowSteps"; +import { getNextStep, getStepIndex, parseReviewReturnSearchParam, CREATE_FLOW_REVIEW_RETURN_QUERY_KEY } from "./utils/flowSteps"; import { getProportionBarProgressForCreateFlowStep } from "./utils/createFlowProportionProgress"; import { createFlowStepUsesCenteredTextLayout, @@ -42,6 +42,7 @@ import { } from "./utils/createFlowFooterClassNames"; import { CUSTOM_RULE_CONFIRM_FOOTER_STEP_BY_STEP, + methodCardFacetSectionForConfirmStep, type CustomRuleConfirmFooterStep, } from "./utils/customRuleConfirmFooterSteps"; import { getDefaultFooterLabel } from "./utils/createFlowFooterLabels"; @@ -111,6 +112,8 @@ function CreateFlowLayoutContent({ const tLogin = useTranslation("pages.login"); const router = useRouter(); const pathname = usePathname(); + const searchParams = useSearchParams(); + const reviewReturnTarget = parseReviewReturnSearchParam(searchParams); const { openLogin } = useAuthModal(); const skipCommunitySave = sessionResolved && Boolean(sessionUser); const { @@ -123,7 +126,7 @@ function CreateFlowLayoutContent({ } = useCreateFlowNavigation( skipCommunitySave ? { skipCommunitySave: true } : undefined, ); - const { state, clearState, updateState, resetCustomRuleSelections } = + const { state, clearState, updateState, resetCustomRuleSelections, setMethodSectionsPinCommitted } = useCreateFlow(); const { draftSaveBannerMessage, setDraftSaveBannerMessage } = useCreateFlowDraftSaveBanner(); @@ -253,13 +256,19 @@ function CreateFlowLayoutContent({ if (titleOk && editingId === last.id && sectionsClear) { return; } - updateState(createFlowStateFromPublishedRule(last)); + updateState({ + ...createFlowStateFromPublishedRule(last), + /** Keep UI-only facet pin flags across published re-hydration (wizard draft field; not stored on publish). */ + methodSectionsPinCommitted: state.methodSectionsPinCommitted, + }); }, [ currentStep, router, updateState, state.editingPublishedRuleId, state.title, + state.methodSectionsPinCommitted, + state.sections?.length, ]); const handleCommunitySaveMagicLinkSubmit = useCallback(async () => { @@ -348,6 +357,13 @@ function CreateFlowLayoutContent({ currentStep != null ? CUSTOM_RULE_CONFIRM_FOOTER_STEP_BY_STEP.get(currentStep) : undefined; + /** Method-card steps tolerate `reviewReturn={edit-rule}` when `edit-rule ∉ FLOW_STEP_ORDER` makes `nextStep` null. Core values stay gated on linear `nextStep`. */ + const showCustomRuleFooterConfirm = + Boolean(customRuleConfirmFooter) && + (nextStep != null || + (reviewReturnTarget != null && + methodCardFacetSectionForConfirmStep(customRuleConfirmFooter.step) != + undefined)); /** * Top banner stack rendered above the main column when any of the @@ -590,7 +606,8 @@ function CreateFlowLayoutContent({ {footer.createFromTemplate} - ) : customRuleConfirmFooter && nextStep ? ( + ) : showCustomRuleFooterConfirm && + customRuleConfirmFooter ? (