Keep the template picker in the create flow, make catalog cards real links, and stop showing a fake community when review has no draft.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,7 +9,13 @@ import type { GovernanceTemplateCatalogEntry } from "../../../../lib/templates/g
|
||||
|
||||
export interface GovernanceTemplateGridProps {
|
||||
entries: GovernanceTemplateCatalogEntry[];
|
||||
onTemplateClick: (_slug: string) => void;
|
||||
/**
|
||||
* Real navigation target per card. Cards render as anchors so they are
|
||||
* keyboard-focusable and work in a new tab.
|
||||
*/
|
||||
hrefForTemplate: (_slug: string) => string;
|
||||
/** Optional side effects on activate (analytics, draft reset). */
|
||||
onTemplateClick?: (_slug: string) => void;
|
||||
/**
|
||||
* When true, use project **`md`** (640px) for a 2-column grid (e.g. `/use-cases`).
|
||||
* Default keeps the template shell break at **768px**.
|
||||
@@ -19,6 +25,7 @@ export interface GovernanceTemplateGridProps {
|
||||
|
||||
export function GovernanceTemplateGrid({
|
||||
entries,
|
||||
hrefForTemplate,
|
||||
onTemplateClick,
|
||||
twoColumnsFromMd = false,
|
||||
}: GovernanceTemplateGridProps) {
|
||||
@@ -105,9 +112,14 @@ export function GovernanceTemplateGrid({
|
||||
/>
|
||||
}
|
||||
backgroundColor={card.backgroundColor}
|
||||
onClick={() => {
|
||||
onTemplateClick(card.slug);
|
||||
}}
|
||||
href={hrefForTemplate(card.slug)}
|
||||
onClick={
|
||||
onTemplateClick
|
||||
? () => {
|
||||
onTemplateClick(card.slug);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
*/
|
||||
|
||||
import { memo, useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
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,
|
||||
isTemplatesFetchAborted,
|
||||
@@ -34,7 +34,6 @@ declare global {
|
||||
|
||||
const RuleStackContainer = memo<RuleStackProps>(
|
||||
({ className = "", initialGridEntries, translationNamespace, twoColumnsFromMd }) => {
|
||||
const router = useRouter();
|
||||
const namespace = translationNamespace ?? "pages.home.ruleStack";
|
||||
const t = useTranslation(namespace);
|
||||
const [gridEntries, setGridEntries] = useState<TemplateGridCardEntry[] | null>(
|
||||
@@ -101,12 +100,12 @@ const RuleStackContainer = memo<RuleStackProps>(
|
||||
// `signedIn: true` because this surface has no session in hand; DELETE is
|
||||
// best-effort and the sentinel blocks stale-draft hydration.
|
||||
prepareFreshCreateFlowEntrySync({ signedIn: true });
|
||||
router.push(`/create/review-template/${encodeURIComponent(slug)}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<RuleStackView
|
||||
className={className}
|
||||
hrefForTemplate={(slug) => buildTemplateReviewHref(slug)}
|
||||
onTemplateClick={handleTemplateClick}
|
||||
gridEntries={gridEntries}
|
||||
sectionTitle={t("title")}
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface RuleStackProps {
|
||||
export interface RuleStackViewProps {
|
||||
className: string;
|
||||
onTemplateClick: (_slug: string) => void;
|
||||
hrefForTemplate: (_slug: string) => string;
|
||||
/** `null` while loading curated templates from the API. */
|
||||
gridEntries: TemplateGridCardEntry[] | null;
|
||||
sectionTitle: string;
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { RuleStackViewProps } from "./RuleStack.types";
|
||||
export function RuleStackView({
|
||||
className,
|
||||
onTemplateClick,
|
||||
hrefForTemplate,
|
||||
gridEntries,
|
||||
sectionTitle,
|
||||
sectionSubtitle,
|
||||
@@ -46,6 +47,7 @@ export function RuleStackView({
|
||||
) : (
|
||||
<GovernanceTemplateGrid
|
||||
entries={gridEntries}
|
||||
hrefForTemplate={hrefForTemplate}
|
||||
onTemplateClick={onTemplateClick}
|
||||
twoColumnsFromMd={twoColumnsFromMd}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user