Final review edit modals created

This commit is contained in:
adilallo
2026-04-20 17:57:17 -06:00
parent c08cd62872
commit a22d53e860
27 changed files with 2410 additions and 620 deletions
+30
View File
@@ -76,6 +76,36 @@ function buildCoreValuePrefill(
};
}
/**
* Variant of {@link buildTemplateCustomizePrefill} that pulls *only* the
* Values section out of a template body. Used by the "Use without changes"
* handler so the verbatim template flow still seeds
* `coreValuesChipsSnapshot` + `selectedCoreValueIds` — without that, the
* final-review screen has no per-chip ids to attach edits to and falls
* back to the read-only chip modal for values.
*
* Returns an empty object when the body is malformed or has no Values
* section.
*/
export function buildCoreValuesPrefillFromTemplateBody(
body: unknown,
): Partial<CreateFlowState> {
if (!body || typeof body !== "object") return {};
const sections = (body as { sections?: unknown }).sections;
if (!Array.isArray(sections)) return {};
for (const raw of sections) {
if (!isTemplateSection(raw)) continue;
const key = normaliseCategoryKey(raw.categoryName as string);
if (key !== "values" && key !== "corevalues") continue;
const titles = entryTitles(raw.entries);
if (titles.length === 0) continue;
return buildCoreValuePrefill(titles);
}
return {};
}
/**
* Map a curated template `body` (DB shape — `sections[]` with `categoryName`
* + `entries[].title`) to the `CreateFlowState` keys the Create Custom Rule