Keep a draft when opening a template from the catalog, instead of deleting it on click.

This commit is contained in:
adilallo committed 2026-11-22 18:08:35 -07:00
1 parent 55b071aa83
commit f634a91bb2
3 files changed
+7 -21

No files matched your search

@@ -5,7 +5,6 @@ import { useSearchParams } from "next/navigation";
import HeaderLockup from "../../components/type/HeaderLockup";
import { GovernanceTemplateGrid } from "../../components/sections/GovernanceTemplateGrid";
import type { TemplateGridCardEntry } from "../../../lib/templates/templateGridPresentation";
import { prepareFreshCreateFlowEntrySync } from "../../(app)/create/utils/prepareFreshCreateFlowEntry";
import { buildTemplateReviewHref } from "../../(app)/create/utils/flowSteps";
import { useTranslation } from "../../contexts/MessagesContext";
@@ -62,8 +61,7 @@ export default function TemplatesPageClient({
}
/**
* - `fromFlow=1` — skip `prepareFreshCreateFlowEntry` on template click
* (draft preserved). Used by profile “Create from template”.
* - `fromFlow=1` — in-wizard catalog; community answers stay until apply.
* Templates carry no recommendation; the grid stays in curated order.
*/
function TemplatesGridWithSearchParams({
@@ -91,13 +89,6 @@ function TemplatesGrid({
hrefForTemplate={(slug) =>
buildTemplateReviewHref(slug, { fromCreateWizard: fromFlow })
}
onTemplateClick={() => {
if (!fromFlow) {
// Marketing /templates has no session in hand; DELETE is
// best-effort and the sentinel blocks stale-draft hydration.
prepareFreshCreateFlowEntrySync({ signedIn: true });
}
}}
/>
);
}
@@ -7,7 +7,6 @@
import { memo, useEffect, useState } from "react";
import { useTranslation } from "../../../contexts/MessagesContext";
import { logger } from "../../../../lib/logger";
import { prepareFreshCreateFlowEntrySync } from "../../../(app)/create/utils/prepareFreshCreateFlowEntry";
import { buildTemplateReviewHref } from "../../../(app)/create/utils/flowSteps";
import {
fetchTemplates,
@@ -96,10 +95,6 @@ const RuleStackContainer = memo<RuleStackProps>(
}
}
logger.debug(`${slug} template clicked`);
// Marketing home “Popular templates”: same fresh start as Top “Create rule”.
// `signedIn: true` because this surface has no session in hand; DELETE is
// best-effort and the sentinel blocks stale-draft hydration.
prepareFreshCreateFlowEntrySync({ signedIn: true });
};
return (