Christmas gifts and timed gift e-mails

- Gifts bought 15 Nov - 6 Jan get a Christmas card ("Boldog karácsonyt és
  csillagos 2027-et!", snowflakes) and a Christmas e-mail subject.
- The buyer can time the gift e-mail (e.g. Christmas morning); "Küldés most"
  replaces a waiting one, a refund takes it back.
- Admin: timed e-mails by hour (waiting / sent / failed), e-mail state per gift.
- /karacsony landing page; seasonal hints on /csomagok and /ajandek.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-24 13:46:35 +00:00
co-authored by Claude Opus 5.5
parent 227e8b5b80
commit 382bd31271
22 changed files with 1016 additions and 209 deletions
+30
View File
@@ -0,0 +1,30 @@
// The Christmas season of the gift campaign (Budapest dates; the backend
// marks the gifts by the same window).
const parts = (now: Date) => {
const [y, m, d] = new Intl.DateTimeFormat("en-CA", {
timeZone: "Europe/Budapest",
year: "numeric",
month: "2-digit",
day: "2-digit",
})
.format(now)
.split("-")
.map(Number);
return { y, m, d };
};
/** 15 November to 6 January: gifts are Christmas gifts (festive card, e-mail). */
export function isChristmasTime(now = new Date()): boolean {
const { m, d } = parts(now);
return (m === 11 && d >= 15) || m === 12 || (m === 1 && d <= 6);
}
/** Christmas morning (24 December, 8:00 Budapest) of this season, if still ahead. */
export function christmasMorning(now = new Date()): Date | null {
const { y, m } = parts(now);
if (m !== 11 && m !== 12) return null;
// 8:00 in Budapest is 7:00 UTC in December (winter time).
const at = new Date(Date.UTC(y, 11, 24, 7, 0));
return at.getTime() > now.getTime() + 10 * 60 * 1000 ? at : null;
}
+10
View File
@@ -660,8 +660,12 @@ export interface AdminGift {
checkout: { id: string; live: boolean | null; amount_huf: number | null } | null;
invoice: { number: string | null; status: string } | null;
storno: { status: string; number: string | null; error: string | null } | null;
send_at: string | null;
email_state: EmailState | null;
}
export type EmailState = "scheduled" | "sending" | "sent" | "failed";
/** A package the user bought as a gift (`GET /v1/gifts`). */
export interface Gift {
id: string;
@@ -678,6 +682,12 @@ export interface Gift {
status: "open" | "redeemed" | "refunded";
redeemed_at: string | null;
refunded_at: string | null;
/** E-mailed at this time (null: at once). */
send_at: string | null;
/** The e-mail: waiting for its time, going out, gone out or failed (null: none, or long gone out). */
email_state: EmailState | null;
/** Bought for Christmas (the card is festive). */
christmas: boolean;
/** E-mails sent so far. */
sendings: number;
/** Whether it can be sent by e-mail (again). */