Keep the photo a community already uploaded when they pick a template from the wizard.
This commit is contained in:
1 parent
6bf890fa78
commit
5dc936834c
6 files changed
+55
-14
No files matched your search
@@ -866,25 +866,19 @@ function CreateFlowLayoutContent({
|
|||||||
valuesCount={customizeDialog?.valuesCount ?? 0}
|
valuesCount={customizeDialog?.valuesCount ?? 0}
|
||||||
cardsCount={customizeDialog?.cardsCount ?? 0}
|
cardsCount={customizeDialog?.cardsCount ?? 0}
|
||||||
initialTitle={
|
initialTitle={
|
||||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
|
fromCreateWizard && typeof state.title === "string"
|
||||||
? typeof state.title === "string"
|
|
||||||
? state.title
|
? state.title
|
||||||
: ""
|
: ""
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
initialDescription={
|
initialDescription={
|
||||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
|
fromCreateWizard && typeof state.communityContext === "string"
|
||||||
? typeof state.communityContext === "string"
|
|
||||||
? state.communityContext
|
? state.communityContext
|
||||||
: ""
|
: ""
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
initialLocation={
|
initialLocation={
|
||||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true
|
fromCreateWizard && typeof state.communityLocation === "string"
|
||||||
? typeof state.communityLocation === "string"
|
|
||||||
? state.communityLocation
|
? state.communityLocation
|
||||||
: ""
|
: ""
|
||||||
: ""
|
|
||||||
}
|
}
|
||||||
onClose={closeCustomizeDialog}
|
onClose={closeCustomizeDialog}
|
||||||
onContinue={confirmCustomizeDialog}
|
onContinue={confirmCustomizeDialog}
|
||||||
|
|||||||
@@ -145,8 +145,7 @@ export function useTemplateReviewActions({
|
|||||||
pathname?.includes("/create/review-template/"),
|
pathname?.includes("/create/review-template/"),
|
||||||
);
|
);
|
||||||
|
|
||||||
const keepInFlowIdentity =
|
const keepInFlowIdentity = fromCreateWizard;
|
||||||
fromCreateWizard && state.templateReviewEntryFromCreateFlow === true;
|
|
||||||
|
|
||||||
const confirmReplaceDraft = useCallback(async (): Promise<boolean> => {
|
const confirmReplaceDraft = useCallback(async (): Promise<boolean> => {
|
||||||
if (!requestConfirm) return true;
|
if (!requestConfirm) return true;
|
||||||
@@ -253,6 +252,7 @@ export function useTemplateReviewActions({
|
|||||||
title: state.title,
|
title: state.title,
|
||||||
communityContext: state.communityContext,
|
communityContext: state.communityContext,
|
||||||
communityLocation: state.communityLocation,
|
communityLocation: state.communityLocation,
|
||||||
|
communityAvatarUrl: state.communityAvatarUrl,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
}),
|
}),
|
||||||
@@ -264,6 +264,7 @@ export function useTemplateReviewActions({
|
|||||||
markCreateFlowInteraction,
|
markCreateFlowInteraction,
|
||||||
replaceState,
|
replaceState,
|
||||||
router,
|
router,
|
||||||
|
state.communityAvatarUrl,
|
||||||
state.communityContext,
|
state.communityContext,
|
||||||
state.communityLocation,
|
state.communityLocation,
|
||||||
signedIn,
|
signedIn,
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@ From that page, **Customize** opens a dialog for name, optional logo, descriptio
|
|||||||
- **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 (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 and pre-fills those three screens. Back from name 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. Direct entry drops a leftover logo and setup answers. **In-flow** picks (`/create/templates?fromFlow=1`) keep the community name, description, place, and photo already given. A hydration latch stops a saved server draft from overwriting the template after apply.
|
||||||
|
|
||||||
| Origin | Click-site behavior | URL the user lands on |
|
| Origin | Click-site behavior | URL the user lands on |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ export type TemplateApplyIdentity = {
|
|||||||
title?: string;
|
title?: string;
|
||||||
communityContext?: string;
|
communityContext?: string;
|
||||||
communityLocation?: string;
|
communityLocation?: string;
|
||||||
|
communityAvatarUrl?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -256,6 +257,7 @@ export function buildAppliedTemplateCreateFlowState(args: {
|
|||||||
const title = args.identity?.title?.trim();
|
const title = args.identity?.title?.trim();
|
||||||
const communityContext = args.identity?.communityContext?.trim();
|
const communityContext = args.identity?.communityContext?.trim();
|
||||||
const communityLocation = args.identity?.communityLocation?.trim();
|
const communityLocation = args.identity?.communityLocation?.trim();
|
||||||
|
const communityAvatarUrl = args.identity?.communityAvatarUrl?.trim();
|
||||||
|
|
||||||
const seeded: CreateFlowState = {
|
const seeded: CreateFlowState = {
|
||||||
...prefill,
|
...prefill,
|
||||||
@@ -274,6 +276,7 @@ export function buildAppliedTemplateCreateFlowState(args: {
|
|||||||
seeded.summary = communityContext;
|
seeded.summary = communityContext;
|
||||||
}
|
}
|
||||||
if (communityLocation) seeded.communityLocation = communityLocation;
|
if (communityLocation) seeded.communityLocation = communityLocation;
|
||||||
|
if (communityAvatarUrl) seeded.communityAvatarUrl = communityAvatarUrl;
|
||||||
if (args.identity) seeded.templateReviewEntryFromCreateFlow = true;
|
if (args.identity) seeded.templateReviewEntryFromCreateFlow = true;
|
||||||
|
|
||||||
if (args.mode === "useWithoutChanges") {
|
if (args.mode === "useWithoutChanges") {
|
||||||
|
|||||||
@@ -248,6 +248,28 @@ describe("buildAppliedTemplateCreateFlowState", () => {
|
|||||||
mode: "useWithoutChanges",
|
mode: "useWithoutChanges",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps an in-flow photo when identity includes it", () => {
|
||||||
|
const seeded = buildAppliedTemplateCreateFlowState({
|
||||||
|
slug: "mutual-aid-mondays",
|
||||||
|
body: {
|
||||||
|
sections: [
|
||||||
|
{
|
||||||
|
categoryName: "Communication",
|
||||||
|
entries: [{ title: "Signal" }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
mode: "useWithoutChanges",
|
||||||
|
identity: {
|
||||||
|
title: "Neighborhood",
|
||||||
|
communityAvatarUrl: " /api/uploads/logo ",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(seeded.title).toBe("Neighborhood");
|
||||||
|
expect(seeded.communityAvatarUrl).toBe("/api/uploads/logo");
|
||||||
|
expect(seeded.templateReviewEntryFromCreateFlow).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("templatePresetDetailsFromPrefill", () => {
|
describe("templatePresetDetailsFromPrefill", () => {
|
||||||
|
|||||||
@@ -145,12 +145,13 @@ describe("useTemplateReviewActions", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("in-flow Use without changes keeps the community name and pins the template path", async () => {
|
it("in-flow Use without changes keeps the community name, photo, and pins the template path", async () => {
|
||||||
const { result } = renderActions(
|
const { result } = renderActions(
|
||||||
{
|
{
|
||||||
title: "Neighborhood",
|
title: "Neighborhood",
|
||||||
communityContext: "We meet weekly",
|
communityContext: "We meet weekly",
|
||||||
templateReviewEntryFromCreateFlow: true,
|
communityLocation: "Oakland",
|
||||||
|
communityAvatarUrl: "/api/uploads/logo",
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
@@ -162,6 +163,8 @@ describe("useTemplateReviewActions", () => {
|
|||||||
expect(router.push).toHaveBeenCalledWith("/create/community-name");
|
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?.communityLocation).toBe("Oakland");
|
||||||
|
expect(applied?.communityAvatarUrl).toBe("/api/uploads/logo");
|
||||||
expect(applied?.setupTraits).toBeUndefined();
|
expect(applied?.setupTraits).toBeUndefined();
|
||||||
expect(applied?.pendingTemplateAction).toEqual({
|
expect(applied?.pendingTemplateAction).toEqual({
|
||||||
slug: "mutual-aid-mondays",
|
slug: "mutual-aid-mondays",
|
||||||
@@ -170,6 +173,24 @@ describe("useTemplateReviewActions", () => {
|
|||||||
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
|
expect(applied?.templateReviewBackSlug).toBe("mutual-aid-mondays");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("a persisted in-flow flag without ?fromFlow=1 clears leftover identity", async () => {
|
||||||
|
const { result } = renderActions(
|
||||||
|
{
|
||||||
|
title: "Neighborhood",
|
||||||
|
communityAvatarUrl: "/api/uploads/logo",
|
||||||
|
templateReviewEntryFromCreateFlow: true,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
await result.current.handleUseWithoutChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(applied?.title).toBeUndefined();
|
||||||
|
expect(applied?.communityAvatarUrl).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
it("asks before replacing a draft in progress", async () => {
|
it("asks before replacing a draft in progress", async () => {
|
||||||
requestConfirm.mockResolvedValueOnce(false);
|
requestConfirm.mockResolvedValueOnce(false);
|
||||||
const { result } = renderActions({ title: "Juniper Street Tenants" });
|
const { result } = renderActions({ title: "Juniper Street Tenants" });
|
||||||
|
|||||||
Reference in new issue
Block a user