From 6498d52541b0b716f6f4a87b5a1173b4c486c2b6 Mon Sep 17 00:00:00 2001 From: adilallo <39313955+adilallo@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:34:33 -0700 Subject: [PATCH] Skip setup questions on the template path and collect name, photo, and description without recommendations. Customize opens a dialog then walks the template decks; Use without changes lands on final review with Has Name Field. Template cards stay first, the engine is not called, and the catalog no longer shows a recommended tag. --- app/(app)/create/CreateFlowLayoutClient.tsx | 23 ++ .../components/TemplateCustomizeDialog.tsx | 256 +++++++++++++++++ .../create/hooks/useCommunityAvatarUpload.ts | 186 +++++++++++++ .../create/hooks/useCreateFlowNavigation.ts | 17 +- .../create/hooks/useMethodCardDeckOrdering.ts | 35 ++- .../usePrefetchMethodFacetRecommendations.ts | 7 +- .../create/hooks/useTemplateReviewActions.ts | 257 +++++++++--------- .../screens/review/CommunityReviewScreen.tsx | 41 +-- .../screens/review/FinalReviewScreen.tsx | 117 ++++++-- .../screens/select/CoreValuesSelectScreen.tsx | 31 ++- .../CreateFlowTemplatesPageClient.tsx | 7 +- app/(app)/create/types.ts | 19 +- app/(app)/create/utils/flowSteps.ts | 72 +++-- .../templates/TemplatesPageClient.tsx | 21 +- .../templates/useTemplatesFacetGridEntries.ts | 71 ----- app/components/cards/Rule/Rule.container.tsx | 22 ++ app/components/cards/Rule/Rule.types.ts | 26 ++ app/components/cards/Rule/Rule.view.tsx | 102 ++++++- docs/create-flow.md | 22 +- docs/guides/template-recommendation-matrix.md | 39 +-- lib/create/applyTemplatePrefill.ts | 66 ++++- lib/create/fetchTemplates.ts | 52 ---- lib/create/templatePath.ts | 92 +++++++ lib/templates/governanceTemplateCatalog.ts | 4 +- lib/templates/templateGridPresentation.ts | 70 +---- .../en/create/community/communityContext.json | 1 + messages/en/create/templateCustomize.json | 40 +++ messages/en/index.ts | 2 + tests/components/ReviewPage.test.tsx | 4 +- tests/pages/create-templates.test.tsx | 1 + tests/pages/templates.test.jsx | 1 + tests/unit/Rule.test.jsx | 33 +++ tests/unit/applyTemplatePrefill.test.ts | 43 +++ tests/unit/flowSteps.test.ts | 91 ++++--- .../hooks/useTemplateReviewActions.test.tsx | 96 ++++--- tests/unit/templateGridFacetScores.test.ts | 123 +-------- tests/unit/templatePath.test.ts | 93 +++++++ 37 files changed, 1450 insertions(+), 733 deletions(-) create mode 100644 app/(app)/create/components/TemplateCustomizeDialog.tsx create mode 100644 app/(app)/create/hooks/useCommunityAvatarUpload.ts delete mode 100644 app/(marketing)/templates/useTemplatesFacetGridEntries.ts create mode 100644 lib/create/templatePath.ts create mode 100644 messages/en/create/templateCustomize.json create mode 100644 tests/unit/templatePath.test.ts diff --git a/app/(app)/create/CreateFlowLayoutClient.tsx b/app/(app)/create/CreateFlowLayoutClient.tsx index 33ce2ab..85496b7 100644 --- a/app/(app)/create/CreateFlowLayoutClient.tsx +++ b/app/(app)/create/CreateFlowLayoutClient.tsx @@ -15,6 +15,7 @@ import { useCreateFlowExit } from "./hooks/useCreateFlowExit"; import { usePrefetchMethodFacetRecommendations } from "./hooks/usePrefetchMethodFacetRecommendations"; import { useCreateFlowFinalize } from "./hooks/useCreateFlowFinalize"; import { useTemplateReviewActions } from "./hooks/useTemplateReviewActions"; +import { TemplateCustomizeDialog } from "./components/TemplateCustomizeDialog"; import { useCompletedRuleShareExport } from "./hooks/useCompletedRuleShareExport"; import CreateFlowFooter from "../../components/navigation/CreateFlowFooter"; import CreateFlowTopNav from "../../components/navigation/CreateFlowTopNav"; @@ -323,6 +324,9 @@ function CreateFlowLayoutContent({ setTemplateReviewApplyError, handleCustomize: handleCustomizeTemplate, handleUseWithoutChanges: handleUseTemplateWithoutChanges, + customizeDialog, + closeCustomizeDialog, + confirmCustomizeDialog, } = useTemplateReviewActions({ pathname, state, @@ -876,6 +880,25 @@ function CreateFlowLayoutContent({ backdropVariant="blurredYellow" ariaLabel={messages.create.topNav.leaveConfirmTitle} /> + , +): string { + const key = String(count); + if ((COUNT_WORD_KEYS as readonly string[]).includes(key)) { + const word = words[key]; + if (typeof word === "string" && word.length > 0) return word; + } + return key; +} + +function countPhrase( + count: number, + one: string, + many: string, + words: Record, +): string { + if (count === 1) return one; + return many.replace("{word}", countWord(count, words)); +} + +export function TemplateCustomizeDialog({ + isOpen, + templateTitle, + valuesCount, + cardsCount, + initialTitle, + initialDescription, + initialLocation, + onClose, + onContinue, +}: { + isOpen: boolean; + templateTitle: string; + valuesCount: number; + cardsCount: number; + initialTitle: string; + initialDescription: string; + initialLocation: string; + onClose: () => void; + onContinue: (_fields: TemplateCustomizeFields) => void; +}) { + const copy = useMessages().create.templateCustomize; + const tName = useTranslation("create.community.communityName"); + const tContext = useTranslation("create.community.communityContext"); + const avatar = useCommunityAvatarUpload(); + + const [title, setTitle] = useState(initialTitle); + const [description, setDescription] = useState(initialDescription); + const [location, setLocation] = useState(initialLocation); + const [attempted, setAttempted] = useState(false); + + useEffect(() => { + if (!isOpen) { + setAttempted(false); + return; + } + setTitle(initialTitle); + setDescription(initialDescription); + setLocation(initialLocation); + }, [isOpen, initialTitle, initialDescription, initialLocation]); + + const words = copy.countWords; + const valuesPhrase = countPhrase( + valuesCount, + copy.valuesOne, + copy.valuesMany, + words, + ); + const cardsPhrase = countPhrase( + cardsCount, + copy.cardsOne, + copy.cardsMany, + words, + ); + const heading = copy.title.replace("{template}", templateTitle); + const lockupDescription = copy.description + .replaceAll("{template}", templateTitle) + .replace("{valuesPhrase}", valuesPhrase) + .replace("{cardsPhrase}", cardsPhrase); + + const trimmedTitle = title.trim(); + const nameError = attempted && trimmedTitle.length === 0; + const canContinue = trimmedTitle.length > 0 && !avatar.busy; + + const nameHint = nameError ? copy.nameRequired : copy.nameHint; + + const handleContinue = () => { + setAttempted(true); + if (!canContinue) return; + onContinue({ + title: trimmedTitle, + communityContext: description.trim(), + communityLocation: location.trim(), + }); + }; + + return ( + + + + } + showBackButton={false} + showCancelButton + showNextButton + cancelButtonText={copy.cancel} + nextButtonText={copy.continue} + nextButtonDisabled={!canContinue} + onCancel={onClose} + onNext={handleContinue} + > +
+ setTitle(event.target.value)} + inputSize="medium" + formHeader + showHelpIcon={false} + textHint={nameHint} + error={nameError} + maxLength={COMMUNITY_TITLE_FIELD_MAX_LENGTH} + required + autoFocus + /> +
+ +
+ void avatar.handleFileChange(event)} + /> + +

+ {avatar.errorMessage ?? + (avatar.fileName && avatar.displaySrc + ? avatar.fileName + : copy.logoHint)} +

+
+
+