@mccaskie-labs/workbench-fundraising 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.js ADDED
@@ -0,0 +1,236 @@
1
+ // '@mccaskie-labs/workbench-fundraising/ui': the campaign page with its
2
+ // progress, the give form and its reader, the supporters' list, the
3
+ // thank-you, the raffle page, the ticket form and its reader, the buyer's
4
+ // tickets, the results, the refusals, and the owner's law check. Plain HTML
5
+ // strings with a `wb-fund-*` class on every element (FUND_STYLES), no script.
6
+ //
7
+ // Results show ticket numbers, never names (docs/raffles.md P-R6). Money is
8
+ // always shown to 2 decimal places in the house style (A$50.00, ₱1,500.00).
9
+ import { formatMoney, toCents } from "./money.js";
10
+ import { FUND_WORDS } from "./words.js";
11
+ export { FUND_WORDS, FUND_WORD_KEYS } from "./words.js";
12
+ export { formatMoney } from "./money.js";
13
+ const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
14
+ function fill(text, params = {}) {
15
+ return text.replace(/\{(\w+)\}/g, (m, k) => (Object.hasOwn(params, k) ? String(params[k]) : m));
16
+ }
17
+ function word(t, key, params = {}) {
18
+ return t?.(`ui.wbfund.${key}`, params) ?? fill(FUND_WORDS.en[key], params);
19
+ }
20
+ /** Escaped words: params are escaped before they go in. */
21
+ function w(o, key, params = {}) {
22
+ const safe = Object.fromEntries(Object.entries(params).map(([k, v]) => [k, typeof v === "string" ? esc(v) : v]));
23
+ return word(o.t, key, safe);
24
+ }
25
+ function locale(country, lang = "en") {
26
+ if (lang === "tl")
27
+ return "fil-PH";
28
+ return country === "PH" ? "en-PH" : country === "AU" ? "en-AU" : "en-GB";
29
+ }
30
+ /** "23 Nov 2026" in the project's time zone. */
31
+ export function formatDate(iso, config, lang = "en") {
32
+ return new Intl.DateTimeFormat(locale(config.country, lang), { day: "numeric", month: "short", year: "numeric", timeZone: config.time_zone }).format(new Date(iso));
33
+ }
34
+ /** "Sat 12 Dec 2026, 7:30 pm" in the project's time zone. */
35
+ export function formatDateTime(iso, config, lang = "en") {
36
+ return new Intl.DateTimeFormat(locale(config.country, lang), { weekday: "short", day: "numeric", month: "short", year: "numeric", hour: "numeric", minute: "2-digit", timeZone: config.time_zone }).format(new Date(iso));
37
+ }
38
+ const m = (cents, c) => formatMoney(cents, c.currency, c.country);
39
+ /** The bar and the raised line. */
40
+ export function renderProgress(totals, config, o = {}) {
41
+ const raised = m(totals.raised_cents, config);
42
+ const bar = totals.goal_cents === null ? "" : `<progress class="wb-fund-bar" max="${totals.goal_cents}" value="${Math.min(totals.raised_cents, totals.goal_cents)}">${totals.percent ?? 0}%</progress>`;
43
+ const line = totals.goal_cents === null ? w(o, "raised", { raised }) : w(o, "raised_of", { raised, goal: m(totals.goal_cents, config) });
44
+ const counts = [w(o, "gifts_count", { count: totals.gifts }), ...(totals.monthly_givers > 0 ? [w(o, "monthly_count", { count: totals.monthly_givers })] : [])].join(" · ");
45
+ return `<div class="wb-fund-progress">${bar}<p class="wb-fund-raised">${line}</p><p class="wb-fund-counts">${counts}</p></div>`;
46
+ }
47
+ /** The story as paragraphs: blank lines split them. Plain text, escaped. */
48
+ function story(text) {
49
+ const paras = text.split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean);
50
+ return paras.length ? `<div class="wb-fund-story">${paras.map((p) => `<p class="wb-fund-para">${esc(p).replace(/\n/g, " ")}</p>`).join("")}</div>` : "";
51
+ }
52
+ /** The campaign's page: picture, title, progress, end date and story. Put renderGiveForm under it. */
53
+ export function renderCampaign(campaign, totals, config, o = {}) {
54
+ const now = o.now ?? new Date();
55
+ const closed = campaign.status === "closed" || (campaign.ends_at !== null && new Date(campaign.ends_at) <= now);
56
+ const img = campaign.image_url ? `<img class="wb-fund-image" src="${esc(campaign.image_url)}" alt="">` : "";
57
+ const ends = !closed && campaign.ends_at ? `<p class="wb-fund-ends">${w(o, "ends", { date: formatDate(campaign.ends_at, config, o.lang) })}</p>` : "";
58
+ const shut = closed ? `<p class="wb-fund-closed">${w(o, "closed")}</p>` : "";
59
+ const permit = config.country === "PH" && config.organisation.solicitation_permit ? `<p class="wb-fund-permit">${w(o, "solicitation", { number: config.organisation.solicitation_permit })}</p>` : "";
60
+ return `<section class="wb-fund-campaign">${img}<h2 class="wb-fund-title">${esc(campaign.title)}</h2>${renderProgress(totals, config, o)}${ends}${shut}${story(campaign.story)}${permit}</section>`;
61
+ }
62
+ /** The give form: the amounts as choices (the middle one chosen), another amount, once or monthly, and the name box. */
63
+ export function renderGiveForm(campaign, config, o) {
64
+ const g = config.gifts;
65
+ if (!g)
66
+ return "";
67
+ const pick = Math.floor((g.amounts.length - 1) / 2);
68
+ const amounts = g.amounts
69
+ .map((a, i) => `<label class="wb-fund-amount"><input class="wb-fund-radio" type="radio" name="amount" value="${toCents(a)}"${i === pick ? " checked" : ""}> ${esc(m(toCents(a), config))}</label>`)
70
+ .join("");
71
+ const other = `<label class="wb-fund-other">${w(o, "other_amount")} <input class="wb-fund-input" type="text" inputmode="decimal" name="other" autocomplete="off"> <span class="wb-fund-range">${w(o, "range", { min: m(toCents(g.min), config), max: m(toCents(g.max), config) })}</span></label>`;
72
+ const often = g.monthly
73
+ ? `<fieldset class="wb-fund-often"><legend class="wb-fund-legend">${w(o, "monthly")}</legend><label class="wb-fund-amount"><input class="wb-fund-radio" type="radio" name="often" value="once" checked> ${w(o, "once")}</label><label class="wb-fund-amount"><input class="wb-fund-radio" type="radio" name="often" value="monthly"> ${w(o, "monthly")}</label></fieldset>`
74
+ : "";
75
+ const names = g.show_names === "ask"
76
+ ? `<label class="wb-fund-check"><input class="wb-fund-checkbox" type="checkbox" name="show_name" value="1"> ${w(o, "show_name")}</label><label class="wb-fund-field">${w(o, "your_name")} <input class="wb-fund-input" type="text" name="name" maxlength="100" autocomplete="name"></label><label class="wb-fund-field">${w(o, "your_message")} <textarea class="wb-fund-textarea" name="message" maxlength="500" rows="2"></textarea></label>`
77
+ : "";
78
+ return `<form class="wb-fund-give" method="post" action="${esc(o.action)}"><h3 class="wb-fund-give-title">${w(o, "give_title")}</h3><input class="wb-fund-hidden" type="hidden" name="campaign" value="${esc(campaign.id)}"><fieldset class="wb-fund-amounts"><legend class="wb-fund-legend">${w(o, "give_title")}</legend>${amounts}${other}</fieldset>${often}${names}<button class="wb-fund-button" type="submit">${w(o, "give_title")}</button></form>`;
79
+ }
80
+ /** Cents from typed money ("25", "25.5", "1,250.00"), read from text, never through a float; null if it isn't money. */
81
+ export function readAmount(typed) {
82
+ const s = typed.replace(/[,\s]/g, "").replace(/^(A\$|\$|₱|PHP|AUD)/i, "");
83
+ const match = /^(\d{1,9})(?:\.(\d{1,2}))?$/.exec(s);
84
+ if (!match)
85
+ return null;
86
+ return Number(match[1]) * 100 + Number((match[2] ?? "0").padEnd(2, "0"));
87
+ }
88
+ /** Reads the give form's post. The amount is checked against the floor and ceiling again by startGift. */
89
+ export function readGiveForm(form, config) {
90
+ const g = config.gifts;
91
+ const str = (k) => {
92
+ const v = form.get(k);
93
+ return typeof v === "string" ? v.trim() : "";
94
+ };
95
+ const typed = str("other");
96
+ const amount = typed ? readAmount(typed) : /^\d{1,11}$/.test(str("amount")) ? Number(str("amount")) : null;
97
+ if (amount === null || amount < 1)
98
+ return { ok: false, reason: "bad_amount" };
99
+ if (g && amount < toCents(g.min))
100
+ return { ok: false, reason: "too_small", min_cents: toCents(g.min), max_cents: toCents(g.max) };
101
+ if (g && amount > toCents(g.max))
102
+ return { ok: false, reason: "too_big", min_cents: toCents(g.min), max_cents: toCents(g.max) };
103
+ const showName = g?.show_names === "ask" && str("show_name") === "1" && str("name") !== "";
104
+ return {
105
+ ok: true,
106
+ campaignId: str("campaign"),
107
+ amountCents: amount,
108
+ monthly: g?.monthly === true && str("often") === "monthly",
109
+ showName,
110
+ ...(showName ? { name: str("name").slice(0, 100) } : {}),
111
+ ...(showName && str("message") ? { message: str("message").slice(0, 500) } : {}),
112
+ };
113
+ }
114
+ /** The supporters' list: names of givers who ticked the box, with their message. No amounts. */
115
+ export function renderSupporters(list, o = {}) {
116
+ if (!list.length)
117
+ return "";
118
+ const items = list.map((s) => `<li class="wb-fund-supporter"><strong class="wb-fund-supporter-name">${esc(s.name)}</strong>${s.message ? ` <span class="wb-fund-supporter-message">${esc(s.message)}</span>` : ""}</li>`).join("");
119
+ return `<section class="wb-fund-supporters"><h3 class="wb-fund-supporters-title">${w(o, "supporters")}</h3><ul class="wb-fund-supporter-list">${items}</ul></section>`;
120
+ }
121
+ /**
122
+ * The thank-you, for the page and the email beside payments' receipt. It
123
+ * says a gift is tax-deductible only when the organisation says it is a
124
+ * deductible gift recipient and gives its ABN (P9).
125
+ */
126
+ export function renderThanks(gift, campaign, config, o = {}) {
127
+ const params = { amount: m(gift.amount_cents, config), campaign: campaign.title, date: formatDate(gift.created_at, config, o.lang) };
128
+ const line = gift.monthly ? w(o, "thanks_monthly", params) : w(o, "thanks_once", params);
129
+ const org = config.organisation;
130
+ const deductible = config.country === "AU" && org.dgr === true && org.abn && gift.kind === "online"
131
+ ? `<p class="wb-fund-deductible">${w(o, "deductible", { min: m(200, config), organisation: org.name, abn: org.abn })}</p>`
132
+ : "";
133
+ return `<section class="wb-fund-thanks"><h2 class="wb-fund-title">${w(o, "thanks_title")}</h2><p class="wb-fund-thanks-text">${line}</p>${deductible}<p class="wb-fund-note">${w(o, "receipt_note")}</p></section>`;
134
+ }
135
+ /** Tickets still to buy. */
136
+ export const ticketsLeft = (r) => Math.max(0, r.max_tickets - r.sold - r.held);
137
+ /** The raffle's page: prizes, price, tickets left, dates, the draw, permit numbers and terms. Put renderTicketForm under it while it's selling. */
138
+ export function renderRaffle(raffle, config, o = {}) {
139
+ const prizes = raffle.prizes
140
+ .map((p) => `<li class="wb-fund-prize"><span class="wb-fund-prize-label">${esc(p.label)}</span> <span class="wb-fund-prize-value">${esc(m(p.value_cents, config))}</span></li>`)
141
+ .join("");
142
+ const left = ticketsLeft(raffle);
143
+ const facts = [
144
+ w(o, "ticket_price", { price: m(raffle.ticket_cents, config) }),
145
+ raffle.status === "selling" ? (left > 0 ? w(o, "tickets_left", { left, max: raffle.max_tickets }) : w(o, "sold_out")) : null,
146
+ w(o, "sales_close", { date: formatDateTime(raffle.sales_end, config, o.lang) }),
147
+ w(o, "draw", { date: formatDateTime(raffle.draw_at, config, o.lang), place: raffle.draw_place }),
148
+ ...Object.entries(raffle.permits).map(([id, number]) => w(o, "permit", { name: o.permitNames?.[id] ?? id.toUpperCase(), number })),
149
+ raffle.adults_only ? w(o, "adults_only") : null,
150
+ ].filter((x) => x !== null);
151
+ const cancelled = raffle.status === "cancelled" ? `<p class="wb-fund-closed">${w(o, "cancelled")}</p>` : "";
152
+ const terms = raffle.terms ? `<p class="wb-fund-terms">${esc(raffle.terms)}</p>` : "";
153
+ return `<section class="wb-fund-raffle"><h2 class="wb-fund-title">${esc(raffle.title)}</h2>${cancelled}<h3 class="wb-fund-give-title">${w(o, "raffle_prizes")}</h3><ol class="wb-fund-prizes">${prizes}</ol><ul class="wb-fund-facts">${facts.map((f) => `<li class="wb-fund-fact">${f}</li>`).join("")}</ul>${terms}</section>`;
154
+ }
155
+ /** The ticket form: how many, name, email, and the 18-or-over box when the raffle needs it. */
156
+ export function renderTicketForm(raffle, config, o) {
157
+ const max = Math.min(config.raffles?.max_per_order ?? 50, ticketsLeft(raffle));
158
+ if (raffle.status !== "selling" || max < 1)
159
+ return "";
160
+ const adult = raffle.adults_only ? `<label class="wb-fund-check"><input class="wb-fund-checkbox" type="checkbox" name="adult" value="1" required> ${w(o, "adult")}</label>` : "";
161
+ return `<form class="wb-fund-give" method="post" action="${esc(o.action)}"><h3 class="wb-fund-give-title">${w(o, "buy")}</h3><input class="wb-fund-hidden" type="hidden" name="raffle" value="${esc(raffle.id)}"><label class="wb-fund-field">${w(o, "how_many")} <input class="wb-fund-input" type="number" name="count" min="1" max="${max}" value="1" required></label><label class="wb-fund-field">${w(o, "buyer_name")} <input class="wb-fund-input" type="text" name="name" maxlength="100" autocomplete="name" required></label><label class="wb-fund-field">${w(o, "buyer_email")} <input class="wb-fund-input" type="email" name="email" maxlength="254" autocomplete="email" required></label>${adult}<button class="wb-fund-button" type="submit">${w(o, "buy")}</button></form>`;
162
+ }
163
+ /** Reads the ticket form's post. holdTickets checks it again. */
164
+ export function readTicketForm(form) {
165
+ const str = (k) => {
166
+ const v = form.get(k);
167
+ return typeof v === "string" ? v.trim() : "";
168
+ };
169
+ const count = /^\d{1,3}$/.test(str("count")) ? Number(str("count")) : 0;
170
+ const name = str("name").slice(0, 100);
171
+ const email = str("email").slice(0, 254);
172
+ if (count < 1 || !name || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email))
173
+ return { ok: false, reason: "bad_input" };
174
+ return { ok: true, raffleId: str("raffle"), count, name, email, adult: str("adult") === "1" };
175
+ }
176
+ /** "1–3, 7" from [1, 2, 3, 7]. */
177
+ export function numberList(numbers) {
178
+ const out = [];
179
+ for (let i = 0; i < numbers.length;) {
180
+ let j = i;
181
+ while (j + 1 < numbers.length && numbers[j + 1] === numbers[j] + 1)
182
+ j++;
183
+ out.push(j > i ? `${numbers[i]}–${numbers[j]}` : `${numbers[i]}`);
184
+ i = j + 1;
185
+ }
186
+ return out.join(", ");
187
+ }
188
+ /** The buyer's tickets, for the page after paying and the email. */
189
+ export function renderTickets(order, raffle, config, o = {}) {
190
+ return `<section class="wb-fund-tickets"><h2 class="wb-fund-title">${w(o, "your_tickets")}</h2><p class="wb-fund-numbers">${w(o, "ticket_numbers", { numbers: numberList(order.numbers) })}</p><p class="wb-fund-note">${w(o, "draw", { date: formatDateTime(raffle.draw_at, config, o.lang), place: raffle.draw_place })}</p><p class="wb-fund-note">${w(o, "good_luck")}</p></section>`;
191
+ }
192
+ /** The results: each prize and its winning ticket number, never a name; with the record, the line anyone can check the draw by. */
193
+ export function renderResults(raffle, results, o = {}) {
194
+ if (raffle.status !== "drawn")
195
+ return `<section class="wb-fund-results"><h2 class="wb-fund-title">${w(o, "results_title")}</h2><p class="wb-fund-note">${w(o, raffle.status === "cancelled" ? "cancelled" : "not_drawn")}</p></section>`;
196
+ const items = results
197
+ .map((r) => `<li class="wb-fund-result"><span class="wb-fund-prize-label">${esc(r.label)}</span> <strong class="wb-fund-result-number">${w(o, "prize_won_by", { number: r.number })}</strong>${r.claimed ? ` <span class="wb-fund-claimed">${w(o, "claimed")}</span>` : ""}</li>`)
198
+ .join("");
199
+ const check = o.record ? `<p class="wb-fund-check-draw">${w(o, "check_draw", { seed: o.record.seed, count: o.record.issued - o.record.void_numbers.length })}</p>` : "";
200
+ return `<section class="wb-fund-results"><h2 class="wb-fund-title">${w(o, "results_title")}</h2><ol class="wb-fund-result-list">${items}</ol>${check}</section>`;
201
+ }
202
+ /** Why a gift or tickets can't go ahead, in the buyer's words. */
203
+ export function renderRefusal(r, config, o = {}) {
204
+ const min = config.gifts ? m(toCents(config.gifts.min), config) : "";
205
+ const max = config.gifts ? m(toCents(config.gifts.max), config) : "";
206
+ let text;
207
+ switch (r.reason) {
208
+ case "too_small":
209
+ text = w(o, "too_small", { min });
210
+ break;
211
+ case "too_big":
212
+ text = w(o, "too_big", { max });
213
+ break;
214
+ case "not_enough_left":
215
+ text = w(o, "not_enough_left", { left: r.left ?? 0 });
216
+ break;
217
+ case "too_many":
218
+ text = w(o, "too_many", { max: r.max ?? config.raffles?.max_per_order ?? 50 });
219
+ break;
220
+ case "not_started":
221
+ text = w(o, "not_started", { date: o.startsAt ? formatDateTime(o.startsAt, config, o.lang) : "" });
222
+ break;
223
+ case "sold_out":
224
+ text = w(o, "sold_out");
225
+ break;
226
+ default:
227
+ text = w(o, r.reason);
228
+ }
229
+ return `<p class="wb-fund-refusal" role="alert">${text}</p>`;
230
+ }
231
+ /** The owner's law check for a raffle: what stops it opening, and what to know. English, as the regulators write. */
232
+ export function renderRaffleCheck(check) {
233
+ const problems = check.problems.length ? `<ul class="wb-fund-law-problems">${check.problems.map((p) => `<li class="wb-fund-law-problem">${esc(p.text)}</li>`).join("")}</ul>` : `<p class="wb-fund-law-ok">The law check found nothing that stops this raffle opening.</p>`;
234
+ const warnings = `<ul class="wb-fund-law-warnings">${check.warnings.map((x) => `<li class="wb-fund-law-warning">${esc(x)}</li>`).join("")}</ul>`;
235
+ return `<section class="wb-fund-law">${problems}${warnings}</section>`;
236
+ }
@@ -0,0 +1,4 @@
1
+ export declare const FUND_WORD_KEYS: readonly ["raised_of", "raised", "gifts_count", "monthly_count", "ends", "closed", "give_title", "give", "give_monthly", "other_amount", "range", "once", "monthly", "show_name", "your_name", "your_message", "supporters", "thanks_title", "thanks_once", "thanks_monthly", "deductible", "receipt_note", "solicitation", "raffle_prizes", "ticket_price", "tickets_left", "sold_out", "sales_close", "draw", "permit", "adults_only", "buy", "how_many", "buyer_name", "buyer_email", "adult", "your_tickets", "ticket_numbers", "good_luck", "results_title", "prize_won_by", "claimed", "check_draw", "not_drawn", "cancelled", "not_live", "too_small", "too_big", "no_monthly", "not_selling", "not_started", "ended", "not_enough_left", "too_many", "adult_required", "too_late", "bad_amount", "bad_input"];
2
+ export type FundWordKey = (typeof FUND_WORD_KEYS)[number];
3
+ /** The words by language, as `ui.wbfund.<key>` would hold them. */
4
+ export declare const FUND_WORDS: Readonly<Record<"en" | "tl" | "taglish", Readonly<Record<FundWordKey, string>>>>;
package/dist/words.js ADDED
@@ -0,0 +1,250 @@
1
+ // What the campaign page, the give form, the thank-you, the raffle page,
2
+ // the tickets and the results say, keyed as the project's strings catalogue
3
+ // keys them (`ui.wbfund.*`), in English, Tagalog and Taglish. A project
4
+ // copies them into its catalogue (or keeps its own) and passes its `t`; a
5
+ // word the catalogue lacks falls back to the English here. The Tagalog and
6
+ // Taglish are starter words: have a fluent reader check them before a client
7
+ // sees them. The owner's law check (checkRaffle) is in English: it is for
8
+ // the owner's page, as the regulators write.
9
+ export const FUND_WORD_KEYS = [
10
+ "raised_of",
11
+ "raised",
12
+ "gifts_count",
13
+ "monthly_count",
14
+ "ends",
15
+ "closed",
16
+ "give_title",
17
+ "give",
18
+ "give_monthly",
19
+ "other_amount",
20
+ "range",
21
+ "once",
22
+ "monthly",
23
+ "show_name",
24
+ "your_name",
25
+ "your_message",
26
+ "supporters",
27
+ "thanks_title",
28
+ "thanks_once",
29
+ "thanks_monthly",
30
+ "deductible",
31
+ "receipt_note",
32
+ "solicitation",
33
+ "raffle_prizes",
34
+ "ticket_price",
35
+ "tickets_left",
36
+ "sold_out",
37
+ "sales_close",
38
+ "draw",
39
+ "permit",
40
+ "adults_only",
41
+ "buy",
42
+ "how_many",
43
+ "buyer_name",
44
+ "buyer_email",
45
+ "adult",
46
+ "your_tickets",
47
+ "ticket_numbers",
48
+ "good_luck",
49
+ "results_title",
50
+ "prize_won_by",
51
+ "claimed",
52
+ "check_draw",
53
+ "not_drawn",
54
+ "cancelled",
55
+ "not_live",
56
+ "too_small",
57
+ "too_big",
58
+ "no_monthly",
59
+ "not_selling",
60
+ "not_started",
61
+ "ended",
62
+ "not_enough_left",
63
+ "too_many",
64
+ "adult_required",
65
+ "too_late",
66
+ "bad_amount",
67
+ "bad_input",
68
+ ];
69
+ const en = {
70
+ raised_of: "{raised} raised of {goal}",
71
+ raised: "{raised} raised",
72
+ gifts_count: "{count} gifts",
73
+ monthly_count: "{count} giving monthly",
74
+ ends: "Ends {date}",
75
+ closed: "This appeal has closed. Thank you to everyone who gave.",
76
+ give_title: "Give",
77
+ give: "Give {amount}",
78
+ give_monthly: "Give {amount} a month",
79
+ other_amount: "Other amount",
80
+ range: "From {min} to {max}",
81
+ once: "Once",
82
+ monthly: "Every month",
83
+ show_name: "Show my name on the supporters' list",
84
+ your_name: "Name to show",
85
+ your_message: "A message (optional)",
86
+ supporters: "Supporters",
87
+ thanks_title: "Thank you",
88
+ thanks_once: "Thank you for your gift of {amount} to {campaign} on {date}.",
89
+ thanks_monthly: "Thank you for giving {amount} a month to {campaign}. This month's gift came in on {date}.",
90
+ deductible: "Gifts of {min} or more to {organisation} (ABN {abn}) are tax deductible. Keep your receipt for your tax return.",
91
+ receipt_note: "Your receipt is attached.",
92
+ solicitation: "DSWD solicitation permit {number}",
93
+ raffle_prizes: "Prizes",
94
+ ticket_price: "Tickets {price} each",
95
+ tickets_left: "{left} of {max} tickets left",
96
+ sold_out: "Sold out",
97
+ sales_close: "Sales close {date}",
98
+ draw: "Drawn {date}, {place}",
99
+ permit: "{name}: {number}",
100
+ adults_only: "Tickets are for people 18 and over.",
101
+ buy: "Buy tickets",
102
+ how_many: "How many tickets",
103
+ buyer_name: "Your name",
104
+ buyer_email: "Your email",
105
+ adult: "I'm 18 or over",
106
+ your_tickets: "Your tickets",
107
+ ticket_numbers: "Your ticket numbers: {numbers}",
108
+ good_luck: "We'll email you if you win. Results go on this page after the draw.",
109
+ results_title: "Results",
110
+ prize_won_by: "Ticket {number}",
111
+ claimed: "Claimed",
112
+ check_draw: "Check this draw: seed {seed}, {count} tickets.",
113
+ not_drawn: "The draw hasn't happened yet.",
114
+ cancelled: "This raffle was cancelled. Everyone who bought a ticket gets their money back.",
115
+ not_live: "This appeal isn't taking gifts right now.",
116
+ too_small: "The smallest gift is {min}.",
117
+ too_big: "The largest gift online is {max}. Get in touch to give more.",
118
+ no_monthly: "Monthly gifts aren't offered here.",
119
+ not_selling: "Tickets aren't on sale yet.",
120
+ not_started: "Tickets go on sale {date}.",
121
+ ended: "Ticket sales have closed.",
122
+ not_enough_left: "Only {left} tickets are left.",
123
+ too_many: "You can buy up to {max} tickets at a time.",
124
+ adult_required: "You need to be 18 or over to buy tickets.",
125
+ too_late: "Sorry, these tickets couldn't be issued. Your money will be refunded.",
126
+ bad_amount: "Enter an amount, such as 25 or 25.50.",
127
+ bad_input: "Check how many tickets, your name and your email.",
128
+ };
129
+ const tl = {
130
+ raised_of: "{raised} ang nalikom sa {goal}",
131
+ raised: "{raised} ang nalikom",
132
+ gifts_count: "{count} na donasyon",
133
+ monthly_count: "{count} ang buwanang nagbibigay",
134
+ ends: "Matatapos sa {date}",
135
+ closed: "Sarado na ang kampanyang ito. Salamat sa lahat ng nagbigay.",
136
+ give_title: "Magbigay",
137
+ give: "Magbigay ng {amount}",
138
+ give_monthly: "Magbigay ng {amount} bawat buwan",
139
+ other_amount: "Ibang halaga",
140
+ range: "Mula {min} hanggang {max}",
141
+ once: "Isang beses",
142
+ monthly: "Bawat buwan",
143
+ show_name: "Ipakita ang pangalan ko sa listahan ng mga sumusuporta",
144
+ your_name: "Pangalang ipapakita",
145
+ your_message: "Mensahe (hindi kailangan)",
146
+ supporters: "Mga sumusuporta",
147
+ thanks_title: "Salamat",
148
+ thanks_once: "Salamat sa iyong donasyon na {amount} sa {campaign} noong {date}.",
149
+ thanks_monthly: "Salamat sa pagbibigay ng {amount} bawat buwan sa {campaign}. Natanggap ang donasyon ngayong buwan noong {date}.",
150
+ deductible: "Ang mga donasyon na {min} pataas sa {organisation} (ABN {abn}) ay maibabawas sa buwis. Itago ang resibo para sa tax return.",
151
+ receipt_note: "Nakalakip ang iyong resibo.",
152
+ solicitation: "DSWD solicitation permit {number}",
153
+ raffle_prizes: "Mga premyo",
154
+ ticket_price: "{price} bawat tiket",
155
+ tickets_left: "{left} sa {max} na tiket ang natitira",
156
+ sold_out: "Ubos na",
157
+ sales_close: "Hanggang {date} ang bentahan",
158
+ draw: "Bubunutin sa {date}, {place}",
159
+ permit: "{name}: {number}",
160
+ adults_only: "Para lamang sa edad 18 pataas ang mga tiket.",
161
+ buy: "Bumili ng tiket",
162
+ how_many: "Ilang tiket",
163
+ buyer_name: "Ang pangalan mo",
164
+ buyer_email: "Ang email mo",
165
+ adult: "18 taong gulang o higit pa ako",
166
+ your_tickets: "Ang iyong mga tiket",
167
+ ticket_numbers: "Mga numero ng tiket mo: {numbers}",
168
+ good_luck: "Mag-e-email kami kung manalo ka. Ilalagay ang resulta sa pahinang ito pagkatapos ng bunutan.",
169
+ results_title: "Resulta",
170
+ prize_won_by: "Tiket {number}",
171
+ claimed: "Nakuha na",
172
+ check_draw: "Suriin ang bunutan: seed {seed}, {count} na tiket.",
173
+ not_drawn: "Hindi pa nagaganap ang bunutan.",
174
+ cancelled: "Kinansela ang raffle na ito. Ibabalik ang pera ng lahat ng bumili ng tiket.",
175
+ not_live: "Hindi tumatanggap ng donasyon ang kampanyang ito ngayon.",
176
+ too_small: "Ang pinakamaliit na donasyon ay {min}.",
177
+ too_big: "Ang pinakamalaking donasyon online ay {max}. Makipag-ugnayan sa amin para magbigay ng higit pa.",
178
+ no_monthly: "Walang buwanang donasyon dito.",
179
+ not_selling: "Hindi pa ibinebenta ang mga tiket.",
180
+ not_started: "Magsisimula ang bentahan ng tiket sa {date}.",
181
+ ended: "Sarado na ang bentahan ng tiket.",
182
+ not_enough_left: "{left} na lang ang natitirang tiket.",
183
+ too_many: "Hanggang {max} na tiket lang ang mabibili sa isang beses.",
184
+ adult_required: "Kailangang 18 taong gulang o higit pa para bumili ng tiket.",
185
+ too_late: "Paumanhin, hindi naibigay ang mga tiket na ito. Ibabalik ang pera mo.",
186
+ bad_amount: "Maglagay ng halaga, gaya ng 25 o 25.50.",
187
+ bad_input: "Suriin ang bilang ng tiket, ang pangalan mo at ang email mo.",
188
+ };
189
+ const taglish = {
190
+ raised_of: "{raised} raised na sa {goal}",
191
+ raised: "{raised} raised na",
192
+ gifts_count: "{count} donations",
193
+ monthly_count: "{count} ang nagbibigay monthly",
194
+ ends: "Ends sa {date}",
195
+ closed: "Closed na ang appeal na ito. Salamat sa lahat ng nag-give.",
196
+ give_title: "Give",
197
+ give: "Give {amount}",
198
+ give_monthly: "Give {amount} every month",
199
+ other_amount: "Ibang amount",
200
+ range: "From {min} hanggang {max}",
201
+ once: "One time",
202
+ monthly: "Every month",
203
+ show_name: "Ipakita ang name ko sa supporters' list",
204
+ your_name: "Name na ipapakita",
205
+ your_message: "Message (optional)",
206
+ supporters: "Supporters",
207
+ thanks_title: "Salamat",
208
+ thanks_once: "Salamat sa donation mo na {amount} sa {campaign} noong {date}.",
209
+ thanks_monthly: "Salamat sa pag-give ng {amount} every month sa {campaign}. Natanggap ang donation this month noong {date}.",
210
+ deductible: "Ang donations na {min} pataas sa {organisation} (ABN {abn}) ay tax deductible. Keep mo ang receipt para sa tax return.",
211
+ receipt_note: "Naka-attach ang receipt mo.",
212
+ solicitation: "DSWD solicitation permit {number}",
213
+ raffle_prizes: "Prizes",
214
+ ticket_price: "{price} per ticket",
215
+ tickets_left: "{left} sa {max} tickets pa ang natitira",
216
+ sold_out: "Sold out na",
217
+ sales_close: "Sales close sa {date}",
218
+ draw: "Draw sa {date}, {place}",
219
+ permit: "{name}: {number}",
220
+ adults_only: "Para sa 18 and over lang ang tickets.",
221
+ buy: "Buy tickets",
222
+ how_many: "Ilang tickets",
223
+ buyer_name: "Name mo",
224
+ buyer_email: "Email mo",
225
+ adult: "18 or over na ako",
226
+ your_tickets: "Your tickets",
227
+ ticket_numbers: "Ticket numbers mo: {numbers}",
228
+ good_luck: "Ie-email ka namin kung manalo ka. Results ay nasa page na ito after the draw.",
229
+ results_title: "Results",
230
+ prize_won_by: "Ticket {number}",
231
+ claimed: "Claimed na",
232
+ check_draw: "Check ang draw: seed {seed}, {count} tickets.",
233
+ not_drawn: "Wala pang draw.",
234
+ cancelled: "Cancelled ang raffle na ito. Ire-refund ang lahat ng bumili ng ticket.",
235
+ not_live: "Hindi tumatanggap ng donations ang appeal na ito ngayon.",
236
+ too_small: "Ang pinaka-maliit na donation ay {min}.",
237
+ too_big: "Ang pinaka-malaking donation online ay {max}. Message us para mag-give ng mas malaki.",
238
+ no_monthly: "Walang monthly donations dito.",
239
+ not_selling: "Hindi pa on sale ang tickets.",
240
+ not_started: "Mag-o-open ang ticket sales sa {date}.",
241
+ ended: "Closed na ang ticket sales.",
242
+ not_enough_left: "{left} tickets na lang ang natitira.",
243
+ too_many: "Up to {max} tickets lang per order.",
244
+ adult_required: "Kailangan 18 or over ka para bumili ng tickets.",
245
+ too_late: "Sorry, hindi na-issue ang tickets na ito. Ire-refund ang pera mo.",
246
+ bad_amount: "Mag-enter ng amount, like 25 or 25.50.",
247
+ bad_input: "Check mo ang dami ng tickets, name at email mo.",
248
+ };
249
+ /** The words by language, as `ui.wbfund.<key>` would hold them. */
250
+ export const FUND_WORDS = { en, tl, taglish };
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@mccaskie-labs/workbench-fundraising",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Fundraising for Workbench apps: campaigns with a goal, gifts of an amount the giver chooses (once or monthly, through the payments tool), cash the owner adds, and raffles checked against Australian state and territory and Philippine raffle law, with tickets sold through payments and a recorded draw anyone can check.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mccaskie-labs/workbench.git",
10
+ "directory": "packages/fundraising"
11
+ },
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
15
+ "sideEffects": false,
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./ui": {
22
+ "types": "./dist/ui.d.ts",
23
+ "default": "./dist/ui.js"
24
+ },
25
+ "./styles": {
26
+ "types": "./dist/styles.d.ts",
27
+ "default": "./dist/styles.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "bin": {
32
+ "workbench-fundraising": "./dist/cli.js"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "CHANGELOG.md"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "typecheck": "tsc -p tsconfig.check.json && tsc -p test/tsconfig.json",
44
+ "test": "vitest run",
45
+ "test:store": "vitest run --config vitest.db.config.ts",
46
+ "build": "node scripts/build.mjs",
47
+ "prepack": "node scripts/build.mjs"
48
+ },
49
+ "dependencies": {
50
+ "@mccaskie-labs/workbench-country": "^0.2.3"
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "24.19.2",
54
+ "postgres": "4.1.0",
55
+ "vitest": "^5.1.0"
56
+ }
57
+ }