Run Use without changes through name, description, and photo so final review never holds an editable field.

This commit is contained in:
adilallo committed 2026-11-24 21:05:40 -07:00
1 parent 53e27ef122
commit 6bf890fa78
13 files changed
+156 -145

No files matched your search

@@ -36,8 +36,9 @@ const blurActiveElement = (): void => {
* {@link parseCreateFlowScreenFromPathname} (flowSteps). Footer Back uses * {@link parseCreateFlowScreenFromPathname} (flowSteps). Footer Back uses
* {@link resolveCreateFlowBackTarget}: template **Customize** walks values * {@link resolveCreateFlowBackTarget}: template **Customize** walks values
* then the four decks, and Back from `core-values` returns to * then the four decks, and Back from `core-values` returns to
* `/create/review-template/{slug}`. **Use without changes** lands on * `/create/review-template/{slug}`. **Use without changes** opens name,
* `final-review`; Back from that step returns to the template. * description, and photo, then `final-review`. Back from name returns to
* the template; Back from final review returns to the photo screen.
* *
* Template review footer Back uses {@link buildTemplateReviewHref}’s * Template review footer Back uses {@link buildTemplateReviewHref}’s
* `?fromFlow=1` marker (and persisted `templateReviewEntryFromCreateFlow`) so * `?fromFlow=1` marker (and persisted `templateReviewEntryFromCreateFlow`) so
@@ -57,9 +57,10 @@ export type UseTemplateReviewActionsResult = {
*/ */
handleCustomize: () => Promise<void>; handleCustomize: () => Promise<void>;
/** /**
* Use without changes: seed the template's cards and go to final review. * Use without changes: seed the template's cards and go to the name screen,
* Direct entry clears leftover identity so the Rule card can collect name, * then description and photo, then final review. Direct entry clears leftover
* photo, and description. In-flow keeps the community answers already given. * identity. In-flow keeps the community answers already given so those
* screens are pre-filled.
*/ */
handleUseWithoutChanges: () => Promise<void>; handleUseWithoutChanges: () => Promise<void>;
customizeDialog: TemplateCustomizeDialogModel | null; customizeDialog: TemplateCustomizeDialogModel | null;
@@ -256,7 +257,7 @@ export function useTemplateReviewActions({
: undefined, : undefined,
}), }),
); );
router.push(createFlowStepPath("final-review")); router.push(createFlowStepPath("community-name"));
}, [ }, [
confirmReplaceDraft, confirmReplaceDraft,
keepInFlowIdentity, keepInFlowIdentity,
@@ -95,8 +95,8 @@ export function CommunityReviewScreen() {
/** /**
* Leftover pin from an older draft: bounce off community review onto the * Leftover pin from an older draft: bounce off community review onto the
* template path. Customize walks the decks; Use without changes lands on * template path. Customize walks the decks; Use without changes opens
* final review. The pin stays so decks skip the engine. * name, then description and photo. The pin stays so decks skip the engine.
* *
* Ref guard covers React 18 StrictMode's double-mount in dev so we don't * Ref guard covers React 18 StrictMode's double-mount in dev so we don't
* fire `router.replace` twice on the same transition. * fire `router.replace` twice on the same transition.
@@ -109,7 +109,7 @@ export function CommunityReviewScreen() {
firedRedirectRef.current = true; firedRedirectRef.current = true;
router.replace( router.replace(
createFlowStepPath( createFlowStepPath(
pending.mode === "customize" ? "core-values" : "final-review", pending.mode === "customize" ? "core-values" : "community-name",
), ),
); );
}, [router, state.pendingTemplateAction]); }, [router, state.pendingTemplateAction]);
@@ -32,19 +32,11 @@ import {
type FinalReviewChipEditPatch, type FinalReviewChipEditPatch,
type FinalReviewChipEditTarget, type FinalReviewChipEditTarget,
} from "../../components/FinalReviewChipEditModal"; } from "../../components/FinalReviewChipEditModal";
import { import { FinalReviewCommunityContextEditModal } from "../../components/FinalReviewCommunityContextEditModal";
FinalReviewCommunityContextEditModal, import { FinalReviewTitleEditModal } from "../../components/FinalReviewTitleEditModal";
COMMUNITY_CONTEXT_FIELD_MAX_LENGTH,
} from "../../components/FinalReviewCommunityContextEditModal";
import {
FinalReviewTitleEditModal,
COMMUNITY_TITLE_FIELD_MAX_LENGTH,
} from "../../components/FinalReviewTitleEditModal";
import { useCommunityAvatarDisplayUrl } from "../../hooks/useCommunityAvatarDisplayUrl"; import { useCommunityAvatarDisplayUrl } from "../../hooks/useCommunityAvatarDisplayUrl";
import { usePreviewSurfaceColor } from "../../hooks/usePreviewSurfaceColor"; import { usePreviewSurfaceColor } from "../../hooks/usePreviewSurfaceColor";
import { useCreateFlowNavigation } from "../../hooks/useCreateFlowNavigation"; import { useCreateFlowNavigation } from "../../hooks/useCreateFlowNavigation";
import { useCommunityAvatarUpload } from "../../hooks/useCommunityAvatarUpload";
import { isTemplateCreatePath } from "../../../../../lib/create/templatePath";
import { createFlowStepForFacetGroup } from "../../utils/facetGroupToCreateFlowStep"; import { createFlowStepForFacetGroup } from "../../utils/facetGroupToCreateFlowStep";
import { isPreviewSurfaceColor } from "../../../../../lib/create/previewSurfaceColor"; import { isPreviewSurfaceColor } from "../../../../../lib/create/previewSurfaceColor";
import { import {
@@ -242,10 +234,7 @@ export function FinalReviewScreen({
[state], [state],
); );
const templatePath = isTemplateCreatePath(state); const avatarUrl = useCommunityAvatarDisplayUrl(state.communityAvatarUrl);
const avatarUpload = useCommunityAvatarUpload();
const serverAvatarUrl = useCommunityAvatarDisplayUrl(state.communityAvatarUrl);
const avatarUrl = avatarUpload.displaySrc ?? serverAvatarUrl;
const storedFallback = const storedFallback =
typeof state.previewSurfaceColor === "string" typeof state.previewSurfaceColor === "string"
? state.previewSurfaceColor ? state.previewSurfaceColor
@@ -308,62 +297,14 @@ export function FinalReviewScreen({
hasTrailingIcon={false} hasTrailingIcon={false}
/> />
) : null} ) : null}
{templatePath ? (
<input
ref={avatarUpload.fileInputRef}
type="file"
className="sr-only"
tabIndex={-1}
accept={avatarUpload.accept}
aria-label={m.create.community.communityUpload.title}
onChange={(event) => void avatarUpload.handleFileChange(event)}
/>
) : null}
<Rule <Rule
title={ruleCardTitle} title={ruleCardTitle}
description={ description={ruleCardDescription}
templatePath ? rawCommunityContextForModal : ruleCardDescription onTitleClick={() => setTitleModalOpen(true)}
}
interactive={!templatePath}
hasNameField={templatePath}
nameValue={rawTitleForModal}
nameLabel={m.create.community.communityName.inputLabel}
namePlaceholder={m.create.community.communityName.placeholder}
onNameChange={
templatePath
? (value) => {
markCreateFlowInteraction();
updateState({
title: value.slice(0, COMMUNITY_TITLE_FIELD_MAX_LENGTH),
});
}
: undefined
}
onTitleClick={
templatePath ? undefined : () => setTitleModalOpen(true)
}
titleEditAriaLabel={t("titleEditModal.ariaEditTitle")} titleEditAriaLabel={t("titleEditModal.ariaEditTitle")}
onDescriptionClick={ onDescriptionClick={() => setCommunityContextModalOpen(true)}
templatePath ? undefined : () => setCommunityContextModalOpen(true)
}
descriptionEmptyHint={descriptionEmptyHint} descriptionEmptyHint={descriptionEmptyHint}
descriptionEditAriaLabel={t("communityContextEditModal.ariaEditDescription")} descriptionEditAriaLabel={t("communityContextEditModal.ariaEditDescription")}
descriptionLabel={m.create.community.communityContext.title}
descriptionPlaceholder={m.create.community.communityContext.placeholder}
descriptionHelperText={m.create.community.communityContext.optional}
onDescriptionChange={
templatePath
? (value) => {
markCreateFlowInteraction();
const next = value.slice(0, COMMUNITY_CONTEXT_FIELD_MAX_LENGTH);
updateState({ communityContext: next, summary: next });
}
: undefined
}
onLogoClick={
templatePath ? avatarUpload.handlePickFile : undefined
}
logoUploadAriaLabel={m.create.community.communityUpload.title}
size={mdUp ? "L" : "M"} size={mdUp ? "L" : "M"}
expanded={true} expanded={true}
descriptionAtBottom descriptionAtBottom
@@ -372,12 +313,10 @@ export function FinalReviewScreen({
logoUrl={avatarUrl ?? undefined} logoUrl={avatarUrl ?? undefined}
logoAlt={ruleCardTitle} logoAlt={ruleCardTitle}
communityInitials={ communityInitials={
avatarUrl || templatePath avatarUrl ? undefined : communityInitialsFromTitle(ruleCardTitle)
? undefined
: communityInitialsFromTitle(ruleCardTitle)
} }
categories={finalReviewCategories} categories={finalReviewCategories}
className={`${CREATE_FLOW_REVIEW_RULE_LAYOUT_CLASS}${surfaceColor ? "" : " invisible"}`} className={`${CREATE_FLOW_REVIEW_RULE_LAYOUT_CLASS}${surfaceColor ? "" : "invisible"}`}
onClick={() => {}} onClick={() => {}}
/> />
<FinalReviewChipEditModal <FinalReviewChipEditModal
@@ -395,28 +334,24 @@ export function FinalReviewScreen({
onClose={() => setActiveReadOnlyDetail(null)} onClose={() => setActiveReadOnlyDetail(null)}
detail={activeReadOnlyDetail} detail={activeReadOnlyDetail}
/> />
{templatePath ? null : ( <FinalReviewTitleEditModal
<> isOpen={titleModalOpen}
<FinalReviewTitleEditModal onClose={() => setTitleModalOpen(false)}
isOpen={titleModalOpen} initialValue={rawTitleForModal}
onClose={() => setTitleModalOpen(false)} onSave={(value) => {
initialValue={rawTitleForModal} markCreateFlowInteraction();
onSave={(value) => { updateState({ title: value });
markCreateFlowInteraction(); }}
updateState({ title: value }); />
}} <FinalReviewCommunityContextEditModal
/> isOpen={communityContextModalOpen}
<FinalReviewCommunityContextEditModal onClose={() => setCommunityContextModalOpen(false)}
isOpen={communityContextModalOpen} initialValue={rawCommunityContextForModal}
onClose={() => setCommunityContextModalOpen(false)} onSave={(value) => {
initialValue={rawCommunityContextForModal} markCreateFlowInteraction();
onSave={(value) => { updateState({ communityContext: value, summary: value });
markCreateFlowInteraction(); }}
updateState({ communityContext: value, summary: value }); />
}}
/>
</>
)}
</CreateFlowLockupCardStepShell> </CreateFlowLockupCardStepShell>
); );
} }
+4 -4
View File
@@ -221,9 +221,9 @@ export interface CreateFlowState {
/** /**
* Set when a user starts from a template (Customize or Use without changes). * Set when a user starts from a template (Customize or Use without changes).
* Kept for the rest of the wizard so community setup is skipped, decks skip * Kept for the rest of the wizard so community setup is skipped, decks skip
* the engine, and final-review Back / identity fields know which path it is. * the engine, and Back knows which path it is. Customize walks values and
* Customize walks values and the four decks; Use without changes lands on * the four decks; Use without changes runs name, description, and photo,
* final review. Cleared when the flow is reset. * then final review. Cleared when the flow is reset.
*/ */
pendingTemplateAction?: { pendingTemplateAction?: {
slug: string; slug: string;
@@ -231,7 +231,7 @@ export interface CreateFlowState {
}; };
/** /**
* Template-review slug to return to from Customize values or from * Template-review slug to return to from Customize values or from
* Use-without-changes final review. Cleared when the flow state is cleared. * Use-without-changes name. Cleared when the flow state is cleared.
*/ */
templateReviewBackSlug?: string; templateReviewBackSlug?: string;
/** /**
+34 -15
View File
@@ -51,29 +51,35 @@ export type CreateFlowNavigationOptions = {
skipCommunitySave?: boolean; skipCommunitySave?: boolean;
/** /**
* Template path. Skips size, kind, scale, maturity, and setup questions. * Template path. Skips size, kind, scale, maturity, and setup questions.
* Customize still walks values and the four decks; Use without changes * Customize still walks values and the four decks; identity is collected
* jumps to final review. Identity is collected in the Customize dialog or * in the Customize dialog. Use without changes runs name, description,
* on the final-review Rule card. * and photo, then jumps to final review (no decks unless + Add opens one).
*/ */
templatePathMode?: "customize" | "useWithoutChanges"; templatePathMode?: "customize" | "useWithoutChanges";
}; };
/** /**
* Community questionnaire skipped on both template-path modes. Identity is * Community questionnaire skipped on both template-path modes.
* collected in the Customize dialog or on the final-review Rule card.
*/ */
const TEMPLATE_PATH_COMMUNITY_SKIP = new Set<CreateFlowStep>([ const TEMPLATE_PATH_COMMUNITY_SKIP = new Set<CreateFlowStep>([
"informational", "informational",
"community-name",
"community-structure", "community-structure",
"community-context",
"community-size", "community-size",
"setup-questions", "setup-questions",
"community-upload",
"community-save", "community-save",
"review", "review",
]); ]);
/**
* Customize collects identity in its dialog, so it also skips name,
* description, and photo. Use without changes runs those three screens.
*/
const TEMPLATE_PATH_CUSTOMIZE_IDENTITY_SKIP = new Set<CreateFlowStep>([
"community-name",
"community-context",
"community-upload",
]);
/** Use without changes does not run values or the four decks unless + Add opens one. */ /** Use without changes does not run values or the four decks unless + Add opens one. */
const TEMPLATE_PATH_DECK_SKIP = new Set<CreateFlowStep>([ const TEMPLATE_PATH_DECK_SKIP = new Set<CreateFlowStep>([
"core-values", "core-values",
@@ -83,13 +89,25 @@ const TEMPLATE_PATH_DECK_SKIP = new Set<CreateFlowStep>([
"conflict-management", "conflict-management",
]); ]);
function isTemplatePathSkippedCommunityStep(
step: CreateFlowStep,
mode: NonNullable<CreateFlowNavigationOptions["templatePathMode"]>,
): boolean {
if (TEMPLATE_PATH_COMMUNITY_SKIP.has(step)) return true;
return (
mode === "customize" && TEMPLATE_PATH_CUSTOMIZE_IDENTITY_SKIP.has(step)
);
}
function shouldSkipStep( function shouldSkipStep(
step: CreateFlowStep, step: CreateFlowStep,
options?: CreateFlowNavigationOptions, options?: CreateFlowNavigationOptions,
): boolean { ): boolean {
if (options?.skipCommunitySave && step === "community-save") return true; if (options?.skipCommunitySave && step === "community-save") return true;
if (!options?.templatePathMode) return false; if (!options?.templatePathMode) return false;
if (TEMPLATE_PATH_COMMUNITY_SKIP.has(step)) return true; if (isTemplatePathSkippedCommunityStep(step, options.templatePathMode)) {
return true;
}
return ( return (
options.templatePathMode === "useWithoutChanges" && options.templatePathMode === "useWithoutChanges" &&
TEMPLATE_PATH_DECK_SKIP.has(step) TEMPLATE_PATH_DECK_SKIP.has(step)
@@ -98,16 +116,16 @@ function shouldSkipStep(
/** /**
* Where to send a template-path draft that reopened on a community setup * Where to send a template-path draft that reopened on a community setup
* step. Customize resumes at values; Use without changes resumes at final * step. Customize resumes at values; Use without changes resumes at name.
* review. Deck steps stay put so final-review + Add can open one. * Deck steps stay put so final-review + Add can open one.
*/ */
export function templatePathSkippedCommunityRedirect( export function templatePathSkippedCommunityRedirect(
currentStep: CreateFlowStep | null | undefined, currentStep: CreateFlowStep | null | undefined,
mode: CreateFlowNavigationOptions["templatePathMode"], mode: CreateFlowNavigationOptions["templatePathMode"],
): CreateFlowStep | null { ): CreateFlowStep | null {
if (!currentStep || !mode) return null; if (!currentStep || !mode) return null;
if (!TEMPLATE_PATH_COMMUNITY_SKIP.has(currentStep)) return null; if (!isTemplatePathSkippedCommunityStep(currentStep, mode)) return null;
return mode === "customize" ? "core-values" : "final-review"; return mode === "customize" ? "core-values" : "community-name";
} }
/** /**
@@ -153,7 +171,8 @@ export function getPreviousStep(
* Template path: * Template path:
* - Customize: Back from `core-values` returns to template review; Back from * - Customize: Back from `core-values` returns to template review; Back from
* `final-review` is the conflict deck. * `final-review` is the conflict deck.
* - Use without changes: Back from `final-review` returns to template review. * - Use without changes: Back from `community-name` returns to template
* review; Back from `final-review` is the photo screen.
*/ */
export type CreateFlowBackTarget = export type CreateFlowBackTarget =
| { kind: "step"; step: CreateFlowStep } | { kind: "step"; step: CreateFlowStep }
@@ -173,7 +192,7 @@ export function resolveCreateFlowBackTarget(
if (currentStep === "core-values" && mode === "customize") { if (currentStep === "core-values" && mode === "customize") {
return { kind: "templateReview", slug }; return { kind: "templateReview", slug };
} }
if (currentStep === "final-review" && mode !== "customize") { if (currentStep === "community-name" && mode !== "customize") {
return { kind: "templateReview", slug }; return { kind: "templateReview", slug };
} }
} }
+6 -6
View File
@@ -16,7 +16,7 @@ The Figma **Create Community** sequence is the **source of truth** for the first
Treat these stages as the **canonical product sections** when adding chrome (e.g. stage headers, progress copy), breaking work across teams, or reusing flows in other surfaces. **Layout kind** is **not** encoded in the URL; it lives in [`CREATE_FLOW_SCREEN_REGISTRY`](../app/(app)/create/utils/createFlowScreenRegistry.ts) (Figma node id + `layoutKind` per step). Figma still names eight layout kinds: **informational**, **text**, **select**, **upload**, **review**, **card**, **right-rail**, **completed**. Question-and-options steps (**select**, **card**, **right-rail**) share [`CreateFlowTwoColumnSelectShell`](../app/(app)/create/components/CreateFlowTwoColumnSelectShell.tsx) and [`Selection`](../app/components/cards/Selection/) size variants (`s` chip, `m` tile, `l` row). `app/(app)/create/screens/` still mirrors the Figma kind names. Treat these stages as the **canonical product sections** when adding chrome (e.g. stage headers, progress copy), breaking work across teams, or reusing flows in other surfaces. **Layout kind** is **not** encoded in the URL; it lives in [`CREATE_FLOW_SCREEN_REGISTRY`](../app/(app)/create/utils/createFlowScreenRegistry.ts) (Figma node id + `layoutKind` per step). Figma still names eight layout kinds: **informational**, **text**, **select**, **upload**, **review**, **card**, **right-rail**, **completed**. Question-and-options steps (**select**, **card**, **right-rail**) share [`CreateFlowTwoColumnSelectShell`](../app/(app)/create/components/CreateFlowTwoColumnSelectShell.tsx) and [`Selection`](../app/components/cards/Selection/) size variants (`s` chip, `m` tile, `l` row). `app/(app)/create/screens/` still mirrors the Figma kind names.
**Create from template:** Starting from a template skips size, kind, scale, maturity, and the six setup questions. The group enters only name, photo, and description. There is no recommendation engine on this path. **Customize** opens a dialog, then walks values and the four decks with the template’s cards first. **Use without changes** skips the dialog and decks and lands on final review with the template’s cards. Identity is collected in the Customize dialog or on the final-review Rule card (Has Name Field). The pin is `pendingTemplateAction: { slug, mode }` on `CreateFlowState`. **Create from template:** Starting from a template skips size, kind, scale, maturity, and the six setup questions. The group enters only name, photo, and description. There is no recommendation engine on this path. **Customize** opens a dialog, then walks values and the four decks with the template’s cards first. **Use without changes** skips the dialog and decks and runs the name, description, and photo screens, then final review with the template’s cards. Identity is collected in the Customize dialog or on those three screens. Final review shows the name and description as text on every path. The pin is `pendingTemplateAction: { slug, mode }` on `CreateFlowState`.
--- ---
@@ -83,13 +83,13 @@ From that page, **Customize** opens a dialog for name, optional logo, descriptio
**Exit on template preview.** Direct catalog / marketing entry (`/create/review-template/[slug]` without `?fromFlow=1`) has nothing to save — top-nav **Exit** clears client state and goes home, with no save-progress modal and no leave confirm. In-flow (`?fromFlow=1`) still has community progress, so Exit keeps the usual save / leave-confirm path. **Exit on template preview.** Direct catalog / marketing entry (`/create/review-template/[slug]` without `?fromFlow=1`) has nothing to save — top-nav **Exit** clears client state and goes home, with no save-progress modal and no leave confirm. In-flow (`?fromFlow=1`) still has community progress, so Exit keeps the usual save / leave-confirm path.
**Use without changes** skips the dialog, seeds the template’s cards (chip ids from [`templateChips.json`](../data/templates/templateChips.json) plus `state.sections` titles), pins `pendingTemplateAction: { slug, mode: "useWithoutChanges" }`, and routes to **`/create/final-review`**. Direct catalog entry clears leftover identity so the Rule card can collect name, photo, and description. In-flow keeps the community answers already given. Continue on final review waits for a name, then opens **Invite your members** with no login. **Finish without inviting** publishes and shows the finished Rule. **Send invitations** while logged out opens **Log in to invite your members** and returns here after the link is followed. Guests can publish without signing in (`POST /api/rules` with `userId` null); stakeholder invites are sent only when a session exists. Every card that reads the group’s share uses three quarters (`LAUNCH_SUPERMAJORITY_SHARE`); final review does not ask for a share. **Use without changes** skips the dialog, seeds the template’s cards (chip ids from [`templateChips.json`](../data/templates/templateChips.json) plus `state.sections` titles), pins `pendingTemplateAction: { slug, mode: "useWithoutChanges" }`, and routes to **`/create/community-name`**. From there Continue walks description (`community-context`, with optional city or region) then photo (`community-upload`), then **`/create/final-review`**. Direct catalog entry clears leftover identity so those screens start empty. In-flow keeps the community answers already given so the screens are pre-filled. Back from name returns to template review; Back from final review returns to the photo screen. Continue on final review waits for a name, then opens **Invite your members** with no login. **Finish without inviting** publishes and shows the finished Rule. **Send invitations** while logged out opens **Log in to invite your members** and returns here after the link is followed. Guests can publish without signing in (`POST /api/rules` with `userId` null); stakeholder invites are sent only when a session exists. Every card that reads the group’s share uses three quarters (`LAUNCH_SUPERMAJORITY_SHARE`); final review does not ask for a share.
**The pin stays for the rest of the wizard** so decks skip the engine, final review shows Has Name Field, and Back knows the path. If a leftover pin lands on `/create/review`, [`CommunityReviewScreen`](../app/(app)/create/screens/review/CommunityReviewScreen.tsx) `replace`s to `core-values` (Customize) or `final-review` (Use without changes). **The pin stays for the rest of the wizard** so decks skip the engine and Back knows the path. If a leftover pin lands on `/create/review`, [`CommunityReviewScreen`](../app/(app)/create/screens/review/CommunityReviewScreen.tsx) `replace`s to `core-values` (Customize) or `community-name` (Use without changes).
- **Customize** — dialog, then values and the four decks, then final review with the dialog’s Community name filled in. Add chips on final review open that template deck or the template values; Confirm returns to final review (`?reviewReturn=final-review`). - **Customize** — dialog, then values and the four decks, then final review with the dialog’s Community name filled in as text. Add chips on final review open that template deck or the template values; Confirm returns to final review (`?reviewReturn=final-review`).
- **Use without changes (direct)** — home Popular templates, `/templates` without `fromFlow`, or a pasted review-template URL. Identity is collected on the final-review Rule card. Back returns to template review. - **Use without changes (direct)** — home Popular templates, `/templates` without `fromFlow`, or a pasted review-template URL. Identity is collected on the name, description, and photo screens. Back from name returns to template review.
- **Use without changes (in-flow)** — `/create/review` → `/create/templates` → template. Community identity is already collected. Back still returns to template review. - **Use without changes (in-flow)** — `/create/review` → `/create/templates` → template. Community identity is already collected and pre-fills those three screens. Back from name still returns to template review.
**Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template with no leftover logo or setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, and place already given. A hydration latch stops a saved server draft from overwriting the template after apply. **Direct entry vs in-flow template pick.** The same `/create/review-template/[slug]` URL is reached from two different origins. **Direct** picks (home Popular templates, `/templates`) do not wipe a draft on click. **Use without changes** and **Customize** ask before replacing a draft, then seed from the template with no leftover logo or setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, and place already given. A hydration latch stops a saved server draft from overwriting the template after apply.
@@ -256,8 +256,9 @@ description dialog, prefills cards via
[`buildTemplateCustomizePrefill`](../../lib/create/applyTemplatePrefill.ts), [`buildTemplateCustomizePrefill`](../../lib/create/applyTemplatePrefill.ts),
and routes to `core-values` (setup questions skipped). Template **Use and routes to `core-values` (setup questions skipped). Template **Use
without changes** writes the template’s cards and routes to without changes** writes the template’s cards and routes to
`final-review`. Identity is collected in the dialog or on the `community-name`, then description and photo, then `final-review`.
final-review Rule card. The pin Identity is collected in the dialog or on those three screens. Final
review shows the name and description as text. The pin
`pendingTemplateAction: { slug, mode: "customize" | "useWithoutChanges" }` `pendingTemplateAction: { slug, mode: "customize" | "useWithoutChanges" }`
stays for the rest of the wizard so decks skip the engine. See stays for the rest of the wizard so decks skip the engine. See
[`docs/create-flow.md`](../create-flow.md). The user exits via [`docs/create-flow.md`](../create-flow.md). The user exits via
+2 -2
View File
@@ -13,8 +13,8 @@ export type TemplateChipSet = Record<DeckId | "coreValues", string[]>;
/** /**
* Persistent template-path pin. Kept for the rest of the wizard so decks skip * Persistent template-path pin. Kept for the rest of the wizard so decks skip
* the engine, final review shows identity fields, and Back knows whether to * the engine and Back knows whether to return to the template, the photo
* return to the template or to the conflict deck. * screen, or the conflict deck.
*/ */
export function templatePathFromState( export function templatePathFromState(
state: Pick<CreateFlowState, "pendingTemplateAction">, state: Pick<CreateFlowState, "pendingTemplateAction">,
+30
View File
@@ -1334,6 +1334,36 @@ describe("FinalReviewScreen — edit published title and description", () => {
expect(screen.getByTestId("rule-description-edit")).toBeInTheDocument(); expect(screen.getByTestId("rule-description-edit")).toBeInTheDocument();
}); });
it("shows name and description as text on the template path, with no text input", async () => {
function TemplatePathHarness() {
const { replaceState } = useCreateFlow();
useLayoutEffect(() => {
replaceState({
title: "Eastside Tenants Union",
communityContext: "Neighbors sharing a building.",
pendingTemplateAction: {
slug: "woodline",
mode: "useWithoutChanges",
},
});
}, [replaceState]);
return <FinalReviewScreen />;
}
render(<TemplatePathHarness />);
await waitFor(() => {
expect(screen.getByText("Eastside Tenants Union")).toBeInTheDocument();
});
expect(
screen.getByText("Neighbors sharing a building."),
).toBeInTheDocument();
expect(
screen.queryByRole("textbox", { name: /Community name/i }),
).not.toBeInTheDocument();
expect(
screen.queryByRole("textbox"),
).not.toBeInTheDocument();
});
it("opens Save modal from title click and updates title", async () => { it("opens Save modal from title click and updates title", async () => {
let latest: CreateFlowState = {}; let latest: CreateFlowState = {};
render( render(
+2 -2
View File
@@ -196,10 +196,10 @@ describe("CommunityReviewScreen — pendingTemplateAction redirect", () => {
expect(testRouter.push).not.toHaveBeenCalled(); expect(testRouter.push).not.toHaveBeenCalled();
}); });
it("redirects Use without changes leftover pins to final review", async () => { it("redirects Use without changes leftover pins to the name screen", async () => {
render(<ReviewWithPendingAction mode="useWithoutChanges" />); render(<ReviewWithPendingAction mode="useWithoutChanges" />);
await waitFor(() => { await waitFor(() => {
expect(testRouter.replace).toHaveBeenCalledWith("/create/final-review"); expect(testRouter.replace).toHaveBeenCalledWith("/create/community-name");
}); });
expect(testRouter.push).not.toHaveBeenCalled(); expect(testRouter.push).not.toHaveBeenCalled();
}); });
+35 -11
View File
@@ -113,29 +113,43 @@ describe("flowSteps", () => {
expect(getPreviousStep("final-review", opts)).toBe("conflict-management"); expect(getPreviousStep("final-review", opts)).toBe("conflict-management");
}); });
it("templatePathMode useWithoutChanges skips community setup and the decks", () => { it("templatePathMode useWithoutChanges runs name, description, and photo, then skips the decks", () => {
const opts = { templatePathMode: "useWithoutChanges" as const }; const opts = { templatePathMode: "useWithoutChanges" as const };
expect(getNextStep("informational", opts)).toBe("final-review"); expect(getNextStep("informational", opts)).toBe("community-name");
expect(getNextStep("community-name", opts)).toBe("final-review"); expect(getNextStep("community-name", opts)).toBe("community-context");
expect(getNextStep("setup-questions", opts)).toBe("final-review"); expect(getNextStep("community-context", opts)).toBe("community-upload");
expect(getNextStep("community-upload", opts)).toBe("final-review");
expect(getNextStep("setup-questions", opts)).toBe("community-upload");
expect(getNextStep("core-values", opts)).toBe("final-review"); expect(getNextStep("core-values", opts)).toBe("final-review");
expect(getNextStep("final-review", opts)).toBe("confirm-stakeholders"); expect(getNextStep("final-review", opts)).toBe("confirm-stakeholders");
expect(getPreviousStep("final-review", opts)).toBeNull(); expect(getPreviousStep("community-name", opts)).toBeNull();
expect(getPreviousStep("community-context", opts)).toBe("community-name");
expect(getPreviousStep("community-upload", opts)).toBe("community-context");
expect(getPreviousStep("final-review", opts)).toBe("community-upload");
}); });
it("templatePathSkippedCommunityRedirect resumes setup steps and leaves decks", () => { it("templatePathSkippedCommunityRedirect resumes setup steps and leaves decks", () => {
expect( expect(
templatePathSkippedCommunityRedirect("setup-questions", "customize"), templatePathSkippedCommunityRedirect("setup-questions", "customize"),
).toBe("core-values"); ).toBe("core-values");
expect(
templatePathSkippedCommunityRedirect("community-name", "customize"),
).toBe("core-values");
expect(templatePathSkippedCommunityRedirect("review", "customize")).toBe( expect(templatePathSkippedCommunityRedirect("review", "customize")).toBe(
"core-values", "core-values",
); );
expect(
templatePathSkippedCommunityRedirect(
"setup-questions",
"useWithoutChanges",
),
).toBe("community-name");
expect( expect(
templatePathSkippedCommunityRedirect( templatePathSkippedCommunityRedirect(
"community-name", "community-name",
"useWithoutChanges", "useWithoutChanges",
), ),
).toBe("final-review"); ).toBeNull();
expect( expect(
templatePathSkippedCommunityRedirect("core-values", "useWithoutChanges"), templatePathSkippedCommunityRedirect("core-values", "useWithoutChanges"),
).toBeNull(); ).toBeNull();
@@ -153,17 +167,27 @@ describe("flowSteps", () => {
templatePathMode: "useWithoutChanges" as const, templatePathMode: "useWithoutChanges" as const,
}; };
expect(getNextStep("community-upload", opts)).toBe("final-review"); expect(getNextStep("community-upload", opts)).toBe("final-review");
expect(getPreviousStep("final-review", opts)).toBeNull(); expect(getPreviousStep("final-review", opts)).toBe("community-upload");
}); });
it("resolveCreateFlowBackTarget returns template review from use-without-changes final-review", () => { it("resolveCreateFlowBackTarget returns template review from use-without-changes name", () => {
expect(
resolveCreateFlowBackTarget(
"community-name",
{ templatePathMode: "useWithoutChanges" },
"mutual-aid-mondays",
),
).toEqual({ kind: "templateReview", slug: "mutual-aid-mondays" });
});
it("resolveCreateFlowBackTarget returns photo from use-without-changes final-review", () => {
expect( expect(
resolveCreateFlowBackTarget( resolveCreateFlowBackTarget(
"final-review", "final-review",
{ templatePathMode: "useWithoutChanges" }, { templatePathMode: "useWithoutChanges" },
"mutual-aid-mondays", "mutual-aid-mondays",
), ),
).toEqual({ kind: "templateReview", slug: "mutual-aid-mondays" }); ).toEqual({ kind: "step", step: "community-upload" });
}); });
it("resolveCreateFlowBackTarget returns template review from customize values", () => { it("resolveCreateFlowBackTarget returns template review from customize values", () => {
@@ -186,10 +210,10 @@ describe("flowSteps", () => {
).toEqual({ kind: "step", step: "conflict-management" }); ).toEqual({ kind: "step", step: "conflict-management" });
}); });
it("resolveCreateFlowBackTarget returns template review when a slug is set without a mode", () => { it("resolveCreateFlowBackTarget returns template review from name when a slug is set without a mode", () => {
expect( expect(
resolveCreateFlowBackTarget( resolveCreateFlowBackTarget(
"final-review", "community-name",
undefined, undefined,
"mutual-aid-mondays", "mutual-aid-mondays",
), ),
@@ -126,14 +126,14 @@ describe("useTemplateReviewActions", () => {
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays"); expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
}); });
it("direct Use without changes goes to final review and clears leftover identity", async () => { it("direct Use without changes goes to the name screen and clears leftover identity", async () => {
const { result } = renderActions({ title: "Neighborhood" }); const { result } = renderActions({ title: "Neighborhood" });
await act(async () => { await act(async () => {
await result.current.handleUseWithoutChanges(); await result.current.handleUseWithoutChanges();
}); });
expect(router.push).toHaveBeenCalledWith("/create/final-review"); expect(router.push).toHaveBeenCalledWith("/create/community-name");
expect(applied?.title).toBeUndefined(); expect(applied?.title).toBeUndefined();
expect(applied?.communityContext).toBeUndefined(); expect(applied?.communityContext).toBeUndefined();
expect(applied?.communityAvatarUrl).toBeUndefined(); expect(applied?.communityAvatarUrl).toBeUndefined();
@@ -159,7 +159,7 @@ describe("useTemplateReviewActions", () => {
await result.current.handleUseWithoutChanges(); await result.current.handleUseWithoutChanges();
}); });
expect(router.push).toHaveBeenCalledWith("/create/final-review"); expect(router.push).toHaveBeenCalledWith("/create/community-name");
expect(applied?.title).toBe("Neighborhood"); expect(applied?.title).toBe("Neighborhood");
expect(applied?.communityContext).toBe("We meet weekly"); expect(applied?.communityContext).toBe("We meet weekly");
expect(applied?.setupTraits).toBeUndefined(); expect(applied?.setupTraits).toBeUndefined();