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:
adilallo committed 2026-11-09 17:34:33 -07:00
1 parent 53d236d0d5
commit 6498d52541
37 files changed
+1450 -733

No files matched your search

+58 -8
View File
@@ -3,10 +3,19 @@ import type {
CreateFlowState,
} from "../../app/(app)/create/types";
import coreValuesMessages from "../../messages/en/create/customRule/coreValues.json";
import templateChipsFile from "../../data/templates/templateChips.json";
import { assignTemplateMethodSlugsToPrefill } from "./customRuleFacets";
import { methodSlugFromTitle } from "./methodSlugFromTitle";
import type { DeckId } from "./deckTypes";
import {
communicationPresetFor,
conflictManagementPresetFor,
coreValuePresetFor,
decisionApproachPresetFor,
membershipPresetFor,
} from "./finalReviewChipPresets";
import {
templateChipsForSlug,
type TemplateChipSet,
} from "./templatePath";
type TemplateEntry = { title: unknown };
type TemplateSection = { categoryName: unknown; entries: unknown };
@@ -101,13 +110,8 @@ function buildCoreValuePrefill(
*
* Returns an empty object for malformed bodies (no sections array).
*/
type TemplateChipSet = Record<DeckId | "coreValues", string[]>;
function prefillFromTemplateChips(slug: string): Partial<CreateFlowState> | null {
const templates = (
templateChipsFile as { templates: Record<string, TemplateChipSet> }
).templates;
const chips = templates[slug];
const chips: TemplateChipSet | null = templateChipsForSlug(slug);
if (!chips) return null;
const selected = new Set(chips.coreValues);
return {
@@ -173,3 +177,49 @@ export function buildCoreValuesPrefillFromTemplateBody(
coreValuesChipsSnapshot: full.coreValuesChipsSnapshot,
};
}
/**
* Catalog copy for each prefilled chip, so a template copy keeps the card
* text instead of opening empty Generate-draft fields.
*/
export function templatePresetDetailsFromPrefill(
prefill: Partial<CreateFlowState>,
): Partial<CreateFlowState> {
const communicationMethodDetailsById: NonNullable<
CreateFlowState["communicationMethodDetailsById"]
> = {};
for (const id of prefill.selectedCommunicationMethodIds ?? []) {
communicationMethodDetailsById[id] = communicationPresetFor(id);
}
const membershipMethodDetailsById: NonNullable<
CreateFlowState["membershipMethodDetailsById"]
> = {};
for (const id of prefill.selectedMembershipMethodIds ?? []) {
membershipMethodDetailsById[id] = membershipPresetFor(id);
}
const decisionApproachDetailsById: NonNullable<
CreateFlowState["decisionApproachDetailsById"]
> = {};
for (const id of prefill.selectedDecisionApproachIds ?? []) {
decisionApproachDetailsById[id] = decisionApproachPresetFor(id);
}
const conflictManagementDetailsById: NonNullable<
CreateFlowState["conflictManagementDetailsById"]
> = {};
for (const id of prefill.selectedConflictManagementIds ?? []) {
conflictManagementDetailsById[id] = conflictManagementPresetFor(id);
}
const coreValueDetailsByChipId: NonNullable<
CreateFlowState["coreValueDetailsByChipId"]
> = {};
for (const id of prefill.selectedCoreValueIds ?? []) {
coreValueDetailsByChipId[id] = coreValuePresetFor(id);
}
return {
communicationMethodDetailsById,
membershipMethodDetailsById,
decisionApproachDetailsById,
conflictManagementDetailsById,
coreValueDetailsByChipId,
};
}