Add sync-help-from-civi script + field-group rendering

Two additions, both touching the form-config story:

1. scripts/sync-help-from-civi.mjs

   Diffs per-field help text in config/form.ts against CustomField rows
   in CiviCRM and (with --write) updates the file in place. Reads env
   from .env.local via Node's --env-file flag. Run as `npm run sync-help`
   or `npm run sync-help -- --write`. A --debug mode prints the parser's
   field list without calling Civi.

   Rationale: this form is low-traffic and help text doesn't change
   often once in production. A manual one-off sync is leaner than
   coupling every page load (or every build) to a Civi API call.

2. fieldGroups: visual clustering of related fields within a section

   New optional FieldGroupConfig overlay on StageSectionConfig — pure
   presentation, names existing fields by name so submit/visibility
   logic walks them unchanged. StageSection.tsx pulls grouped fields
   out of the standalone per-field grid and renders each group as its
   own bordered card with an optional heading. Stage 2 now clusters
   Market Study, Pro Forma, Business Plan, and Board Self Assessment
   (each a date + upload pair) into their own cards.
This commit is contained in:
Joel Brock
2026-05-21 12:27:22 -07:00
parent 9460e8320f
commit 2ca2d378a4
5 changed files with 499 additions and 4 deletions
+32
View File
@@ -128,6 +128,29 @@ export interface MatrixGroupConfig {
}>;
}
/**
* Visual cluster for closely-related fields inside a section — e.g. a
* "Market Study" pair (date + file upload) that should read as one item
* with two inputs. Pure presentation: fields referenced here still live
* in `StageSectionConfig.fields` and submit/visibility logic walks them
* the same way as standalone fields. The renderer pulls grouped fields
* out of the section's per-field grid and renders them in their own
* bordered card above (or interleaved with) the ungrouped fields.
*/
export interface FieldGroupConfig {
/** Unique id within the section, e.g. "market_study". */
id: string;
/** Group heading shown above the cluster. Omit for a heading-less card. */
label?: string;
/** Optional helper text rendered below the label. */
intro?: string;
/**
* Names of fields in the parent section that belong to this group, in
* left-to-right / top-to-bottom render order.
*/
fields: string[];
}
export interface StageSectionConfig {
/** Stage rank, 0..5. Used by the conditional engine and the accordion. */
rank: number;
@@ -144,6 +167,15 @@ export interface StageSectionConfig {
*/
visibleWhen?: VisibilityRule;
fields: FieldConfig[];
/**
* Optional visual clusters of related fields. Fields referenced here are
* still defined in `fields` above; this list is an overlay that tells the
* renderer to draw them as a sub-card with a shared heading. A field
* named in more than one group is rendered in the first group it appears
* in. Field-level `visibleWhen` still applies inside a group — a fully
* hidden group renders nothing.
*/
fieldGroups?: FieldGroupConfig[];
/**
* Matrix groups rendered above the per-field grid. Fields referenced in
* any matrix are excluded from the per-field grid (so a Y1 monthly sales