From 00c484d102791e6d380c8c573b076448bbac7073 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 18 Apr 2026 02:04:41 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/lib/forms-shared.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/lib/forms-shared.ts b/src/lib/forms-shared.ts index 714e795..88bf9c1 100644 --- a/src/lib/forms-shared.ts +++ b/src/lib/forms-shared.ts @@ -102,6 +102,7 @@ export function applyVariables( homeowner?: HomeownerLite | null; firmName?: string; customValues?: Record; + fieldValues?: Record; }, ): string { const today = format(new Date(), "MMMM d, yyyy"); @@ -119,15 +120,42 @@ export function applyVariables( for (const [k, v] of Object.entries(replacements)) { out = out.split(k).join(v); } - // Custom variables like {{custom.mortgage_holder}} + // Custom case-field variables like {{custom.mortgage_holder}} if (ctx.customValues) { for (const [k, v] of Object.entries(ctx.customValues)) { out = out.split(`{{custom.${k}}}`).join(v ?? ""); } } + // Per-form fillable fields like {{field.tenant_name}} + if (ctx.fieldValues) { + for (const [k, v] of Object.entries(ctx.fieldValues)) { + out = out.split(`{{field.${k}}}`).join(v ?? ""); + } + } return out; } +// ---------- Per-template fillable fields ---------- +export type FormFieldType = + | "text" + | "textarea" + | "number" + | "date" + | "dropdown" + | "county" + | "client" + | "homeowner"; + +export interface FormFieldDef { + key: string; + label: string; + type: FormFieldType; + required?: boolean; + options?: string[]; // for dropdown + placeholder?: string; + default?: string; +} + export function fmtCurrency(n: number | string | null | undefined): string { const v = typeof n === "string" ? parseFloat(n) : (n ?? 0); return (Number.isFinite(v) ? v : 0).toLocaleString("en-US", {