fix
All checks were successful
Build And Deploy Main / build-and-deploy (push) Successful in 40s

This commit is contained in:
2026-03-12 14:08:53 -04:00
parent 015ab2b934
commit e2c00597e7
2 changed files with 13 additions and 9 deletions

View File

@@ -96,11 +96,14 @@ const formatUtcToLocalHm = (dateLike) => {
return parsed.tz(TARGET_TIMEZONE).format("HH:mm");
};
const safeSetField = (form, fieldName, value) => {
const safeSetField = (form, fieldName, value, options = {}) => {
if (!fieldName || value === undefined || value === null) return;
const text = `${value}`;
try {
const field = form.getTextField(fieldName);
if (typeof options.fontSize === "number") {
field.setFontSize(options.fontSize);
}
field.setText(text);
return;
} catch (_textErr) {}
@@ -146,7 +149,8 @@ const buildRoutePdfBuffer = async (templateBytes, route, seqNum, driversMap, veh
safeSetField(form, `name_${row}`, customer?.customer_name || "");
safeSetField(form, `addr_${row}`, customer?.customer_address || "");
safeSetField(form, `phone_${row}`, customer?.customer_phone || "");
safeSetField(form, `note_${row}`, customer?.customer_note || "");
const customerNoteText = customer?.customer_note || customer?.customer_special_needs || "";
safeSetField(form, `note_${row}`, customerNoteText);
const pickupTime = formatUtcToLocalHm(customer?.customer_pickup_time);
if (pickupTime) safeSetField(form, `pick_${row}`, pickupTime);
@@ -157,14 +161,14 @@ const buildRoutePdfBuffer = async (templateBytes, route, seqNum, driversMap, veh
if (enterCenterTime) {
safeSetField(form, `arrive_${row}`, enterCenterTime);
}
safeSetField(form, `y_${row}`, "✓");
safeSetField(form, `n_${row}`, "");
safeSetField(form, `y_${row}`, "✓", { fontSize: 11 });
safeSetField(form, `n_${row}`, "", { fontSize: 11 });
} else if (customer?.customer_route_status === "inCenter") {
safeSetField(form, `y_${row}`, "✓");
safeSetField(form, `n_${row}`, "");
safeSetField(form, `y_${row}`, "✓", { fontSize: 11 });
safeSetField(form, `n_${row}`, "", { fontSize: 11 });
} else {
safeSetField(form, `y_${row}`, "");
safeSetField(form, `n_${row}`, "✕");
safeSetField(form, `y_${row}`, "", { fontSize: 11 });
safeSetField(form, `n_${row}`, "✕", { fontSize: 11 });
}
const outboundStatus = findOutboundStatusByCustomerId(outboundCustomerStatuses, customer?.customer_id);