BlueGit

timfa questward

Files

questward / shared / courier / systemLetters.js

systemLetters.js

systemLetters.js 1.1 KiB Download Raw
1/** Shared helpers for system-authored letters (CE, bank, bounty, …). */
2
3export const CENTRAL_EXCHANGE_ORG = "Central Exchange";
4export const BANK_LETTER_AUTHOR = "The Bank";
5export const BOUNTY_OFFICE_AUTHOR = "Bounty Office";
6
7export 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
16export 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 */
26export 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}