| 1 | /** Shared helpers for system-authored letters (CE, bank, bounty, …). */ |
| 2 | |
| 3 | export const CENTRAL_EXCHANGE_ORG = "Central Exchange"; |
| 4 | export const BANK_LETTER_AUTHOR = "The Bank"; |
| 5 | export const BOUNTY_OFFICE_AUTHOR = "Bounty Office"; |
| 6 | |
| 7 | export function isCentralExchangeLetter (instance) |
| 8 | { |
| 9 | if (instance?.kind !== "letter") |
| 10 | { return false; } |
| 11 | if (instance.centralExchange === true) |
| 12 | { return true; } |
| 13 | return instance.authorOrganization === CENTRAL_EXCHANGE_ORG; |
| 14 | } |
| 15 | |
| 16 | export function isBankRestNoticeLetter (instance) |
| 17 | { |
| 18 | return instance?.kind === "letter" && instance.bankRestNotice === true; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Format the UI "Signed:" block. Optional organization is a second line under the name. |
| 23 | * @param {{ authorDisplayName?: string, authorOrganization?: string|null }} instance |
| 24 | * @param {string} [fallbackName] |
| 25 | */ |
| 26 | export function formatLetterSignature (instance, fallbackName = "Unknown") |
| 27 | { |
| 28 | const name = String(instance?.authorDisplayName ?? "").trim() || fallbackName; |
| 29 | const org = String(instance?.authorOrganization ?? "").trim(); |
| 30 | return org ? `Signed:\n${name}\n${org}` : `Signed:\n${name}`; |
| 31 | } |