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.
This commit is contained in:
1 parent
53d236d0d5
commit
6498d52541
37 files changed
+1450
-733
No files matched your search
@@ -19,7 +19,6 @@ import {
|
||||
getAssetPath,
|
||||
vectorMarkPath,
|
||||
} from "../../../../../lib/assetUtils";
|
||||
import { methodSectionsPinsForHydratedSelections } from "../../../../../lib/create/publishedDocumentToCreateFlowState";
|
||||
import { CREATE_ROUTES, createFlowStepPath } from "../../utils/createFlowPaths";
|
||||
import { CREATE_FLOW_REVIEW_RETURN_QUERY_KEY } from "../../utils/flowSteps";
|
||||
import type { CreateFlowStep } from "../../types";
|
||||
@@ -83,7 +82,7 @@ export function CommunityReviewScreen() {
|
||||
const lgUp = useCreateFlowLgUp();
|
||||
const messages = useMessages();
|
||||
const t = useTranslation("create.community.review");
|
||||
const { state, updateState } = useCreateFlow();
|
||||
const { state } = useCreateFlow();
|
||||
/**
|
||||
* Server layout has an empty context; the client layout may already hold a
|
||||
* named draft. Defer empty-vs-congrats until after mount so the first paint
|
||||
@@ -95,11 +94,9 @@ export function CommunityReviewScreen() {
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* If the user picked **Customize** from a template before finishing community
|
||||
* stage, we pinned `pendingTemplateAction` so this screen can skip itself
|
||||
* and `replace` to `core-values`. **Use without changes** does not skip
|
||||
* identity: if they land here with that pin, send them to `community-name`
|
||||
* and leave the pin so name → description → photo stay in the skip list.
|
||||
* Leftover pin from an older draft: bounce off community review onto the
|
||||
* template path. Customize walks the decks; Use without changes lands on
|
||||
* final review. The pin stays so decks skip the engine.
|
||||
*
|
||||
* Ref guard covers React 18 StrictMode's double-mount in dev so we don't
|
||||
* fire `router.replace` twice on the same transition.
|
||||
@@ -109,31 +106,13 @@ export function CommunityReviewScreen() {
|
||||
if (firedRedirectRef.current) return;
|
||||
const pending = state.pendingTemplateAction;
|
||||
if (!pending) return;
|
||||
if (pending.mode !== "customize") {
|
||||
firedRedirectRef.current = true;
|
||||
router.replace(createFlowStepPath("community-name"));
|
||||
return;
|
||||
}
|
||||
const target = createFlowStepPath("core-values");
|
||||
firedRedirectRef.current = true;
|
||||
const pinMerge = {
|
||||
methodSectionsPinCommitted: {
|
||||
...state.methodSectionsPinCommitted,
|
||||
...methodSectionsPinsForHydratedSelections(state),
|
||||
},
|
||||
};
|
||||
updateState({ pendingTemplateAction: undefined, ...pinMerge });
|
||||
router.replace(target);
|
||||
}, [
|
||||
router,
|
||||
state.pendingTemplateAction,
|
||||
state.methodSectionsPinCommitted,
|
||||
state.selectedCommunicationMethodIds,
|
||||
state.selectedMembershipMethodIds,
|
||||
state.selectedDecisionApproachIds,
|
||||
state.selectedConflictManagementIds,
|
||||
updateState,
|
||||
]);
|
||||
router.replace(
|
||||
createFlowStepPath(
|
||||
pending.mode === "customize" ? "core-values" : "final-review",
|
||||
),
|
||||
);
|
||||
}, [router, state.pendingTemplateAction]);
|
||||
|
||||
const cardTitle =
|
||||
typeof state.title === "string" && state.title.trim().length > 0
|
||||
|
||||
@@ -29,11 +29,19 @@ import {
|
||||
type FinalReviewChipEditPatch,
|
||||
type FinalReviewChipEditTarget,
|
||||
} from "../../components/FinalReviewChipEditModal";
|
||||
import { FinalReviewCommunityContextEditModal } from "../../components/FinalReviewCommunityContextEditModal";
|
||||
import { FinalReviewTitleEditModal } from "../../components/FinalReviewTitleEditModal";
|
||||
import {
|
||||
FinalReviewCommunityContextEditModal,
|
||||
COMMUNITY_CONTEXT_FIELD_MAX_LENGTH,
|
||||
} from "../../components/FinalReviewCommunityContextEditModal";
|
||||
import {
|
||||
FinalReviewTitleEditModal,
|
||||
COMMUNITY_TITLE_FIELD_MAX_LENGTH,
|
||||
} from "../../components/FinalReviewTitleEditModal";
|
||||
import { useCommunityAvatarDisplayUrl } from "../../hooks/useCommunityAvatarDisplayUrl";
|
||||
import { usePreviewSurfaceColor } from "../../hooks/usePreviewSurfaceColor";
|
||||
import { useCreateFlowNavigation } from "../../hooks/useCreateFlowNavigation";
|
||||
import { useCommunityAvatarUpload } from "../../hooks/useCommunityAvatarUpload";
|
||||
import { isTemplateCreatePath } from "../../../../../lib/create/templatePath";
|
||||
import { createFlowStepForFacetGroup } from "../../utils/facetGroupToCreateFlowStep";
|
||||
import { isPreviewSurfaceColor } from "../../../../../lib/create/previewSurfaceColor";
|
||||
import {
|
||||
@@ -225,7 +233,10 @@ export function FinalReviewScreen({
|
||||
|
||||
const descriptionEmptyHint = t("communityContextEditModal.emptyHint");
|
||||
|
||||
const avatarUrl = useCommunityAvatarDisplayUrl(state.communityAvatarUrl);
|
||||
const templatePath = isTemplateCreatePath(state);
|
||||
const avatarUpload = useCommunityAvatarUpload();
|
||||
const serverAvatarUrl = useCommunityAvatarDisplayUrl(state.communityAvatarUrl);
|
||||
const avatarUrl = avatarUpload.displaySrc ?? serverAvatarUrl;
|
||||
const storedFallback =
|
||||
typeof state.previewSurfaceColor === "string"
|
||||
? state.previewSurfaceColor
|
||||
@@ -275,23 +286,73 @@ export function FinalReviewScreen({
|
||||
hasTrailingIcon={false}
|
||||
/>
|
||||
) : 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
|
||||
title={ruleCardTitle}
|
||||
description={ruleCardDescription}
|
||||
onTitleClick={() => setTitleModalOpen(true)}
|
||||
description={
|
||||
templatePath ? rawCommunityContextForModal : ruleCardDescription
|
||||
}
|
||||
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")}
|
||||
onDescriptionClick={() => setCommunityContextModalOpen(true)}
|
||||
onDescriptionClick={
|
||||
templatePath ? undefined : () => setCommunityContextModalOpen(true)
|
||||
}
|
||||
descriptionEmptyHint={descriptionEmptyHint}
|
||||
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"}
|
||||
expanded={true}
|
||||
descriptionAtBottom
|
||||
backgroundColor="bg-transparent"
|
||||
surfaceColor={surfaceColor}
|
||||
logoUrl={avatarUrl}
|
||||
logoUrl={avatarUrl ?? undefined}
|
||||
logoAlt={ruleCardTitle}
|
||||
communityInitials={
|
||||
avatarUrl ? undefined : communityInitialsFromTitle(ruleCardTitle)
|
||||
avatarUrl || templatePath
|
||||
? undefined
|
||||
: communityInitialsFromTitle(ruleCardTitle)
|
||||
}
|
||||
categories={finalReviewCategories}
|
||||
className={`${CREATE_FLOW_REVIEW_RULE_LAYOUT_CLASS}${surfaceColor ? "" : " invisible"}`}
|
||||
@@ -312,24 +373,28 @@ export function FinalReviewScreen({
|
||||
onClose={() => setActiveReadOnlyDetail(null)}
|
||||
detail={activeReadOnlyDetail}
|
||||
/>
|
||||
<FinalReviewTitleEditModal
|
||||
isOpen={titleModalOpen}
|
||||
onClose={() => setTitleModalOpen(false)}
|
||||
initialValue={rawTitleForModal}
|
||||
onSave={(value) => {
|
||||
markCreateFlowInteraction();
|
||||
updateState({ title: value });
|
||||
}}
|
||||
/>
|
||||
<FinalReviewCommunityContextEditModal
|
||||
isOpen={communityContextModalOpen}
|
||||
onClose={() => setCommunityContextModalOpen(false)}
|
||||
initialValue={rawCommunityContextForModal}
|
||||
onSave={(value) => {
|
||||
markCreateFlowInteraction();
|
||||
updateState({ communityContext: value, summary: value });
|
||||
}}
|
||||
/>
|
||||
{templatePath ? null : (
|
||||
<>
|
||||
<FinalReviewTitleEditModal
|
||||
isOpen={titleModalOpen}
|
||||
onClose={() => setTitleModalOpen(false)}
|
||||
initialValue={rawTitleForModal}
|
||||
onSave={(value) => {
|
||||
markCreateFlowInteraction();
|
||||
updateState({ title: value });
|
||||
}}
|
||||
/>
|
||||
<FinalReviewCommunityContextEditModal
|
||||
isOpen={communityContextModalOpen}
|
||||
onClose={() => setCommunityContextModalOpen(false)}
|
||||
initialValue={rawCommunityContextForModal}
|
||||
onSave={(value) => {
|
||||
markCreateFlowInteraction();
|
||||
updateState({ communityContext: value, summary: value });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</CreateFlowLockupCardStepShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user