diff --git a/app/(app)/create/CreateFlowLayoutClient.tsx b/app/(app)/create/CreateFlowLayoutClient.tsx index 85496b7..89e0d01 100644 --- a/app/(app)/create/CreateFlowLayoutClient.tsx +++ b/app/(app)/create/CreateFlowLayoutClient.tsx @@ -25,6 +25,7 @@ import { CREATE_FLOW_REVIEW_RETURN_QUERY_KEY, getNextStep, parseReviewReturnSearchParam, + templatePathSkippedCommunityRedirect, shouldOfferCreateFlowSaveAndExit, isDirectTemplateReviewEntry, createFlowStepUsesSelectSplitScroll, @@ -101,6 +102,7 @@ import { EMPTY_SETUP_TRAITS, hasTickedSetupTrait, } from "../../../lib/create/setupTraits"; +import { templatePathFromState } from "../../../lib/create/templatePath"; import { useAuthModal } from "../../contexts/AuthModalContext"; import { useMessages, useTranslation } from "../../contexts/MessagesContext"; import { PostLoginDraftTransfer } from "./PostLoginDraftTransfer"; @@ -424,7 +426,18 @@ function CreateFlowLayoutContent({ await runAuthenticatedExit(opts); }; + const templatePathRedirect = templatePathSkippedCommunityRedirect( + currentStep, + templatePathFromState(state)?.mode, + ); + useEffect(() => { + if (!templatePathRedirect) return; + router.replace(createFlowStepPath(templatePathRedirect)); + }, [router, templatePathRedirect]); + + useEffect(() => { + if (templatePathRedirect) return; if ( sessionResolved && sessionUser && @@ -432,7 +445,7 @@ function CreateFlowLayoutContent({ ) { router.replace(CREATE_ROUTES.review); } - }, [sessionResolved, sessionUser, currentStep, router]); + }, [sessionResolved, sessionUser, currentStep, router, templatePathRedirect]); useEffect(() => { clearAttempted(); @@ -967,9 +980,9 @@ function CreateFlowLayoutContent({
- {children} + {templatePathRedirect ? null : children}
- {!isCompletedStep && ( + {!isCompletedStep && !templatePathRedirect && ( { expect(getPreviousStep("final-review", opts)).toBeNull(); }); + it("templatePathSkippedCommunityRedirect resumes setup steps and leaves decks", () => { + expect( + templatePathSkippedCommunityRedirect("setup-questions", "customize"), + ).toBe("core-values"); + expect(templatePathSkippedCommunityRedirect("review", "customize")).toBe( + "core-values", + ); + expect( + templatePathSkippedCommunityRedirect( + "community-name", + "useWithoutChanges", + ), + ).toBe("final-review"); + expect( + templatePathSkippedCommunityRedirect("core-values", "useWithoutChanges"), + ).toBeNull(); + expect( + templatePathSkippedCommunityRedirect("final-review", "customize"), + ).toBeNull(); + expect( + templatePathSkippedCommunityRedirect("setup-questions", undefined), + ).toBeNull(); + }); + it("templatePathMode composes with skipCommunitySave", () => { const opts = { skipCommunitySave: true,