Defer property assessor email gate

This commit is contained in:
2026-03-27 23:27:51 -05:00
parent f8c998d579
commit 1f23eac52c
10 changed files with 185 additions and 104 deletions
+27 -1
View File
@@ -20,6 +20,7 @@ export interface AssessPropertyResult {
ok: true;
needsAssessmentPurpose: boolean;
needsRecipientEmails: boolean;
pdfReady: boolean;
message: string;
outputPath: string | null;
reportPayload: ReportPayload | null;
@@ -58,6 +59,13 @@ function asStringArray(value: unknown): string[] {
return [String(value).trim()].filter(Boolean);
}
function shouldRenderPdf(
options: AssessPropertyOptions,
recipientEmails: string[]
): boolean {
return Boolean(options.output || recipientEmails.length);
}
function slugify(value: string): string {
return value
.toLowerCase()
@@ -371,6 +379,7 @@ export async function assessProperty(
ok: true,
needsAssessmentPurpose: true,
needsRecipientEmails: false,
pdfReady: false,
message:
"Missing assessment purpose. Stop and ask the user why they want this property assessed before producing a decision-grade analysis.",
outputPath: null,
@@ -403,12 +412,14 @@ export async function assessProperty(
photoResolution.photoReview
);
const recipientEmails = asStringArray(options.recipientEmails);
const renderPdf = shouldRenderPdf(options, recipientEmails);
if (!recipientEmails.length) {
if (renderPdf && !recipientEmails.length) {
return {
ok: true,
needsAssessmentPurpose: false,
needsRecipientEmails: true,
pdfReady: false,
message:
"Missing target email. Stop and ask the user for target email address(es) before generating or sending the property assessment PDF.",
outputPath: null,
@@ -417,6 +428,20 @@ export async function assessProperty(
};
}
if (!renderPdf) {
return {
ok: true,
needsAssessmentPurpose: false,
needsRecipientEmails: false,
pdfReady: true,
message:
"Assessment payload is ready to render later. Review the analysis now; recipient email is only needed when you want the PDF.",
outputPath: null,
reportPayload,
publicRecords
};
}
const outputPath =
options.output ||
path.join(
@@ -429,6 +454,7 @@ export async function assessProperty(
ok: true,
needsAssessmentPurpose: false,
needsRecipientEmails: false,
pdfReady: true,
message: `Property assessment PDF rendered: ${renderedPath}`,
outputPath: renderedPath,
reportPayload,