Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
3a08bdbb96
commit
c9e01ce8fe
@@ -52,6 +52,8 @@ export function LetterGenerator() {
|
||||
const [contacts, setContacts] = useState<ContactLite[]>([]);
|
||||
const [caseContactIds, setCaseContactIds] = useState<Set<string>>(new Set());
|
||||
const [recipientId, setRecipientId] = useState("");
|
||||
const [recipientAddress, setRecipientAddress] = useState("");
|
||||
const [recipientEdited, setRecipientEdited] = useState(false);
|
||||
const [firm, setFirm] = useState<FirmInfo | null>(null);
|
||||
const [logoDataUrl, setLogoDataUrl] = useState<string | null>(null);
|
||||
const [attorneyName, setAttorneyName] = useState("");
|
||||
@@ -76,6 +78,12 @@ export function LetterGenerator() {
|
||||
return { linked, others };
|
||||
}, [contacts, caseContactIds]);
|
||||
|
||||
// Auto-fill recipient address block from selected contact (unless user edited it).
|
||||
useEffect(() => {
|
||||
if (recipientEdited) return;
|
||||
setRecipientAddress(contactMailingLines(recipient).join("\n"));
|
||||
}, [recipient, recipientEdited]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchFirm().then(async (f) => {
|
||||
setFirm(f);
|
||||
@@ -244,13 +252,17 @@ export function LetterGenerator() {
|
||||
doc.text(fmtDateLong(date), centerX, y, { align: "center" });
|
||||
y += 28;
|
||||
|
||||
// ----- Recipient (from selected contact) -----
|
||||
// ----- Recipient (editable address block) -----
|
||||
doc.setFont(bodyFont, "normal");
|
||||
doc.setFontSize(bodyFontSize);
|
||||
contactMailingLines(recipient).forEach((l) => {
|
||||
doc.text(l, margin, y);
|
||||
y += lh - 1;
|
||||
});
|
||||
recipientAddress
|
||||
.split("\n")
|
||||
.map((l) => l.trimEnd())
|
||||
.filter((l) => l.length > 0)
|
||||
.forEach((l) => {
|
||||
doc.text(l, margin, y);
|
||||
y += lh - 1;
|
||||
});
|
||||
|
||||
// Certified mail line (right-aligned, italic) — only when a number is provided
|
||||
if (certifiedMailNumber.trim() && template.showCertifiedMail !== false) {
|
||||
@@ -264,11 +276,12 @@ export function LetterGenerator() {
|
||||
|
||||
y += 18;
|
||||
if (renderedSubject) {
|
||||
doc.setFont(bodyFont, "bold");
|
||||
const subjLines = doc.splitTextToSize(`Re: ${renderedSubject}`, maxW);
|
||||
doc.text(subjLines, margin, y);
|
||||
y += subjLines.length * lh + 14;
|
||||
// Re: line — not bold, indented from the left margin.
|
||||
doc.setFont(bodyFont, "normal");
|
||||
const reIndent = 72; // ~1 inch indent
|
||||
const subjLines = doc.splitTextToSize(`Re: ${renderedSubject}`, maxW - reIndent);
|
||||
doc.text(subjLines, margin + reIndent, y);
|
||||
y += subjLines.length * lh + 14;
|
||||
}
|
||||
|
||||
// ----- Body (reserve room for footer) -----
|
||||
|
||||
Reference in New Issue
Block a user