Compare commits
21 Commits
ezpz
...
e5d2b13b21
| Author | SHA1 | Date | |
|---|---|---|---|
|
e5d2b13b21
|
|||
|
7f431c0091
|
|||
|
17aa8956a7
|
|||
|
5e5efcaf6f
|
|||
|
0c8e827cda
|
|||
|
42156209d8
|
|||
|
569ee4ec40
|
|||
|
29250f8694
|
|||
|
f214660ab2
|
|||
|
ba0804db30
|
|||
|
d25f4aa813
|
|||
|
8a6d3035cb
|
|||
|
0a849bd9c5
|
|||
|
17c6315dad
|
|||
|
e59a588a9d
|
|||
|
dfc8ace186
|
|||
|
439bbc5545
|
|||
|
89043c60a3
|
|||
|
7eabe88d30
|
|||
|
d180a33d6e
|
|||
|
cf47f25a4d
|
@@ -30,6 +30,7 @@
|
||||
"@tanstack/react-start": "^1.141.1",
|
||||
"@tanstack/router-plugin": "^1.141.1",
|
||||
"better-auth": "catalog:",
|
||||
"canvas-confetti": "^1.9.4",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"dotenv": "catalog:",
|
||||
@@ -51,11 +52,13 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/vite-plugin": "^1.17.1",
|
||||
"@tanstack/router-core": "^1.141.1",
|
||||
"@kk/config": "workspace:*",
|
||||
"@tanstack/react-query-devtools": "^5.91.1",
|
||||
"@tanstack/react-router-devtools": "^1.141.1",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/react": "^16.2.0",
|
||||
"@types/canvas-confetti": "^1.9.0",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "19.2.7",
|
||||
"@types/react-dom": "19.2.3",
|
||||
|
||||
260
apps/web/src/components/homepage/CountdownBanner.tsx
Normal file
260
apps/web/src/components/homepage/CountdownBanner.tsx
Normal file
@@ -0,0 +1,260 @@
|
||||
import { useState } from "react";
|
||||
import { REGISTRATION_OPENS_AT } from "@/lib/opening";
|
||||
import { useRegistrationOpen } from "@/lib/useRegistrationOpen";
|
||||
import { client } from "@/utils/orpc";
|
||||
|
||||
function pad(n: number): string {
|
||||
return String(n).padStart(2, "0");
|
||||
}
|
||||
|
||||
interface UnitBoxProps {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
function UnitBox({ value, label }: UnitBoxProps) {
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<div className="flex w-14 items-center justify-center rounded-sm bg-white/10 px-2 py-2 font-['Intro',sans-serif] text-3xl text-white tabular-nums sm:w-auto sm:px-4 sm:py-3 sm:text-5xl md:text-6xl lg:text-7xl">
|
||||
{value}
|
||||
</div>
|
||||
<span className="font-['Intro',sans-serif] text-[9px] text-white/50 uppercase tracking-widest sm:text-xs">
|
||||
{label}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Reminder opt-in form — sits at the very bottom of the banner
|
||||
function ReminderForm() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [status, setStatus] = useState<
|
||||
"idle" | "loading" | "subscribed" | "already_subscribed" | "error"
|
||||
>("idle");
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!email || status === "loading") return;
|
||||
|
||||
setStatus("loading");
|
||||
try {
|
||||
const result = await client.subscribeReminder({ email });
|
||||
if (!result.ok && result.reason === "already_open") {
|
||||
setStatus("idle");
|
||||
return;
|
||||
}
|
||||
setStatus("subscribed");
|
||||
} catch (err) {
|
||||
setErrorMessage(err instanceof Error ? err.message : "Er ging iets mis.");
|
||||
setStatus("error");
|
||||
}
|
||||
}
|
||||
|
||||
const reminderTime = REGISTRATION_OPENS_AT.toLocaleTimeString("nl-BE", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className="w-full"
|
||||
style={{
|
||||
animation: "reminderFadeIn 0.6s ease both",
|
||||
animationDelay: "0.3s",
|
||||
}}
|
||||
>
|
||||
<style>{`
|
||||
@keyframes reminderFadeIn {
|
||||
from { opacity: 0; transform: translateY(8px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
@keyframes reminderCheck {
|
||||
from { opacity: 0; transform: scale(0.7); }
|
||||
to { opacity: 1; transform: scale(1); }
|
||||
}
|
||||
`}</style>
|
||||
|
||||
{/* Hairline divider */}
|
||||
<div
|
||||
className="mx-auto mb-6 h-px w-24"
|
||||
style={{
|
||||
background:
|
||||
"linear-gradient(to right, transparent, rgba(255,255,255,0.15), transparent)",
|
||||
}}
|
||||
/>
|
||||
|
||||
{status === "subscribed" || status === "already_subscribed" ? (
|
||||
<div
|
||||
className="flex flex-col items-center gap-2"
|
||||
style={{
|
||||
animation: "reminderCheck 0.4s cubic-bezier(0.34,1.56,0.64,1) both",
|
||||
}}
|
||||
>
|
||||
{/* Checkmark glyph */}
|
||||
<div
|
||||
className="flex h-8 w-8 items-center justify-center rounded-full"
|
||||
style={{
|
||||
background: "rgba(255,255,255,0.12)",
|
||||
border: "1px solid rgba(255,255,255,0.2)",
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
aria-label="Vinkje"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M2.5 7L5.5 10L11.5 4"
|
||||
stroke="white"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<p
|
||||
className="font-['Intro',sans-serif] text-sm tracking-wide"
|
||||
style={{ color: "rgba(255,255,255,0.65)" }}
|
||||
>
|
||||
Herinnering ingepland voor {reminderTime}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col items-center gap-3">
|
||||
<p
|
||||
className="font-['Intro',sans-serif] text-xs uppercase tracking-widest"
|
||||
style={{ color: "rgba(255,255,255,0.35)", letterSpacing: "0.14em" }}
|
||||
>
|
||||
Herinnering ontvangen?
|
||||
</p>
|
||||
|
||||
{/* Fused pill input + button */}
|
||||
<form
|
||||
onSubmit={handleSubmit}
|
||||
className="flex w-full max-w-xs overflow-hidden"
|
||||
style={{
|
||||
borderRadius: "3px",
|
||||
border: "1px solid rgba(255,255,255,0.18)",
|
||||
background: "rgba(255,255,255,0.07)",
|
||||
backdropFilter: "blur(6px)",
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="email"
|
||||
required
|
||||
placeholder="jouw@email.be"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
disabled={status === "loading"}
|
||||
className="min-w-0 flex-1 bg-transparent px-4 py-2.5 text-sm text-white outline-none disabled:opacity-50"
|
||||
style={{
|
||||
fontFamily: "'Intro', sans-serif",
|
||||
fontSize: "0.8rem",
|
||||
letterSpacing: "0.02em",
|
||||
}}
|
||||
/>
|
||||
{/* Vertical separator */}
|
||||
<div
|
||||
style={{
|
||||
width: "1px",
|
||||
background: "rgba(255,255,255,0.15)",
|
||||
flexShrink: 0,
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={status === "loading" || !email}
|
||||
className="shrink-0 px-4 py-2.5 font-semibold text-xs transition-all disabled:opacity-40"
|
||||
style={{
|
||||
fontFamily: "'Intro', sans-serif",
|
||||
letterSpacing: "0.06em",
|
||||
color:
|
||||
status === "loading"
|
||||
? "rgba(255,255,255,0.5)"
|
||||
: "rgba(255,255,255,0.9)",
|
||||
background: "transparent",
|
||||
cursor:
|
||||
status === "loading" || !email ? "not-allowed" : "pointer",
|
||||
whiteSpace: "nowrap",
|
||||
}}
|
||||
>
|
||||
{status === "loading" ? "…" : "Stuur mij"}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{status === "error" && (
|
||||
<p
|
||||
className="font-['Intro',sans-serif] text-xs"
|
||||
style={{ color: "rgba(255,140,140,0.8)" }}
|
||||
>
|
||||
{errorMessage}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shown in place of the registration form while registration is not yet open.
|
||||
*/
|
||||
export function CountdownBanner() {
|
||||
const { isOpen, days, hours, minutes, seconds } = useRegistrationOpen();
|
||||
|
||||
// Once open the parent component will unmount this — but render nothing just in case
|
||||
if (isOpen) return null;
|
||||
|
||||
const openDate = REGISTRATION_OPENS_AT.toLocaleDateString("nl-BE", {
|
||||
weekday: "long",
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
});
|
||||
const openTime = REGISTRATION_OPENS_AT.toLocaleTimeString("nl-BE", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-6 py-4 text-center sm:gap-8">
|
||||
<div>
|
||||
<p className="font-['Intro',sans-serif] text-base text-white/70 sm:text-lg md:text-xl">
|
||||
Inschrijvingen openen op
|
||||
</p>
|
||||
<p className="mt-1 font-['Intro',sans-serif] text-lg text-white capitalize sm:text-xl md:text-2xl">
|
||||
{openDate} om {openTime}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Countdown — single row forced via grid, scales down on small screens */}
|
||||
<div className="grid grid-cols-[auto_auto_auto_auto_auto_auto_auto] items-center gap-1.5 sm:flex sm:gap-4 md:gap-6">
|
||||
<UnitBox value={String(days)} label="dagen" />
|
||||
<span className="mb-6 font-['Intro',sans-serif] text-2xl text-white/40 sm:text-4xl">
|
||||
:
|
||||
</span>
|
||||
<UnitBox value={pad(hours)} label="uren" />
|
||||
<span className="mb-6 font-['Intro',sans-serif] text-2xl text-white/40 sm:text-4xl">
|
||||
:
|
||||
</span>
|
||||
<UnitBox value={pad(minutes)} label="minuten" />
|
||||
<span className="mb-6 font-['Intro',sans-serif] text-2xl text-white/40 sm:text-4xl">
|
||||
:
|
||||
</span>
|
||||
<UnitBox value={pad(seconds)} label="seconden" />
|
||||
</div>
|
||||
|
||||
<p className="max-w-md px-4 text-sm text-white/50">
|
||||
Kom snel terug! Zodra de inschrijvingen openen kun je je hier
|
||||
registreren als toeschouwer of als artiest.
|
||||
</p>
|
||||
|
||||
{/* Email reminder opt-in — always last */}
|
||||
<ReminderForm />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,46 +1,74 @@
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
import confetti from "canvas-confetti";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { CountdownBanner } from "@/components/homepage/CountdownBanner";
|
||||
import { PerformerForm } from "@/components/registration/PerformerForm";
|
||||
import { SuccessScreen } from "@/components/registration/SuccessScreen";
|
||||
import { TypeSelector } from "@/components/registration/TypeSelector";
|
||||
import { WatcherForm } from "@/components/registration/WatcherForm";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import { useRegistrationOpen } from "@/lib/useRegistrationOpen";
|
||||
|
||||
function fireConfetti() {
|
||||
const colors = ["#d82560", "#52979b", "#d09035", "#214e51", "#ffffff"];
|
||||
|
||||
confetti({
|
||||
particleCount: 120,
|
||||
spread: 80,
|
||||
origin: { x: 0.3, y: 0.6 },
|
||||
colors,
|
||||
});
|
||||
setTimeout(() => {
|
||||
confetti({
|
||||
particleCount: 120,
|
||||
spread: 80,
|
||||
origin: { x: 0.7, y: 0.6 },
|
||||
colors,
|
||||
});
|
||||
}, 200);
|
||||
setTimeout(() => {
|
||||
confetti({
|
||||
particleCount: 80,
|
||||
spread: 100,
|
||||
origin: { x: 0.5, y: 0.5 },
|
||||
colors,
|
||||
});
|
||||
}, 400);
|
||||
}
|
||||
|
||||
type RegistrationType = "performer" | "watcher";
|
||||
|
||||
interface SuccessState {
|
||||
token: string;
|
||||
email: string;
|
||||
name: string;
|
||||
function redirectToSignup(email: string) {
|
||||
const params = new URLSearchParams({
|
||||
signup: "1",
|
||||
email,
|
||||
next: "/account",
|
||||
});
|
||||
window.location.href = `/login?${params.toString()}`;
|
||||
}
|
||||
|
||||
export default function EventRegistrationForm() {
|
||||
const { data: session } = authClient.useSession();
|
||||
const { isOpen } = useRegistrationOpen();
|
||||
const confettiFired = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && !confettiFired.current) {
|
||||
confettiFired.current = true;
|
||||
fireConfetti();
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const [selectedType, setSelectedType] = useState<RegistrationType | null>(
|
||||
null,
|
||||
);
|
||||
const [successState, setSuccessState] = useState<SuccessState | null>(null);
|
||||
|
||||
const isLoggedIn = !!session?.user;
|
||||
const user = session?.user as { name?: string; email?: string } | undefined;
|
||||
|
||||
// Split "Jan De Smet" → firstName="Jan", lastName="De Smet"
|
||||
const nameParts = (user?.name ?? "").trim().split(/\s+/);
|
||||
const prefillFirstName = nameParts[0] ?? "";
|
||||
const prefillLastName = nameParts.slice(1).join(" ");
|
||||
const prefillEmail = user?.email ?? "";
|
||||
|
||||
if (successState) {
|
||||
if (!isOpen) {
|
||||
return (
|
||||
<SuccessScreen
|
||||
token={successState.token}
|
||||
email={successState.email}
|
||||
name={successState.name}
|
||||
onReset={() => {
|
||||
setSuccessState(null);
|
||||
setSelectedType(null);
|
||||
}}
|
||||
/>
|
||||
<section
|
||||
id="registration"
|
||||
className="relative z-30 w-full bg-[#214e51]/96 px-6 py-16 md:px-12"
|
||||
>
|
||||
<div className="mx-auto w-full max-w-6xl">
|
||||
<CountdownBanner />
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,54 +87,18 @@ export default function EventRegistrationForm() {
|
||||
<p className="mb-8 max-w-3xl text-lg text-white/80 md:text-xl">
|
||||
Doe je mee of kom je kijken? Kies je rol en vul het formulier in.
|
||||
</p>
|
||||
{/* Login nudge — shown only to guests */}
|
||||
{!isLoggedIn && (
|
||||
<div className="mb-10 flex flex-col gap-3 rounded-lg border border-[#52979b]/40 bg-[#52979b]/10 px-5 py-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<p className="text-sm text-white/80">
|
||||
<span className="mr-1 font-semibold text-teal-300">
|
||||
Al een account?
|
||||
</span>
|
||||
Log in om je gegevens automatisch in te vullen en je Drinkkaart
|
||||
direct te activeren na registratie.
|
||||
</p>
|
||||
<div className="flex shrink-0 items-center gap-3 text-sm">
|
||||
<Link
|
||||
to="/login"
|
||||
className="font-medium text-teal-300 underline-offset-2 transition-colors hover:underline"
|
||||
>
|
||||
Inloggen
|
||||
</Link>
|
||||
<span className="text-white/30">·</span>
|
||||
<Link
|
||||
to="/login"
|
||||
search={{ signup: "1" }}
|
||||
className="text-white/60 transition-colors hover:text-white"
|
||||
>
|
||||
Nog geen account? Aanmaken
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!selectedType && <TypeSelector onSelect={setSelectedType} />}
|
||||
{selectedType === "performer" && (
|
||||
<PerformerForm
|
||||
onBack={() => setSelectedType(null)}
|
||||
onSuccess={(token, email, name) =>
|
||||
setSuccessState({ token, email, name })
|
||||
}
|
||||
prefillFirstName={prefillFirstName}
|
||||
prefillLastName={prefillLastName}
|
||||
prefillEmail={prefillEmail}
|
||||
isLoggedIn={isLoggedIn}
|
||||
onSuccess={(_token, email, _name) => redirectToSignup(email)}
|
||||
/>
|
||||
)}
|
||||
{selectedType === "watcher" && (
|
||||
<WatcherForm
|
||||
onBack={() => setSelectedType(null)}
|
||||
prefillFirstName={prefillFirstName}
|
||||
prefillLastName={prefillLastName}
|
||||
prefillEmail={prefillEmail}
|
||||
isLoggedIn={isLoggedIn}
|
||||
onSuccess={(_token, email, _name) => redirectToSignup(email)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
75
apps/web/src/components/homepage/HoeInschrijven.tsx
Normal file
75
apps/web/src/components/homepage/HoeInschrijven.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
export default function HoeInschrijven() {
|
||||
return (
|
||||
<section className="relative z-25 w-full bg-[#f8f8f8] px-6 py-16 md:px-12">
|
||||
<div className="mx-auto max-w-6xl">
|
||||
<h2 className="mb-4 font-['Intro',sans-serif] text-4xl text-[#214e51] md:text-5xl">
|
||||
Hoe schrijf ik mij in?
|
||||
</h2>
|
||||
<p className="mb-10 max-w-3xl text-[#214e51]/70 text-lg">
|
||||
Inschrijven doe je eenvoudig via deze website zodra de inschrijvingen
|
||||
openen.
|
||||
</p>
|
||||
|
||||
{/* Step cards */}
|
||||
<div className="grid gap-6 md:grid-cols-3">
|
||||
{/* Step 1 */}
|
||||
<div className="flex flex-col gap-3 rounded-2xl border border-[#214e51]/15 bg-white p-6 shadow-sm">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-[#d82560] font-['Intro',sans-serif] font-bold text-lg text-white">
|
||||
1
|
||||
</div>
|
||||
<h3 className="font-['Intro',sans-serif] text-[#214e51] text-xl">
|
||||
Kies je rol
|
||||
</h3>
|
||||
<p className="text-[#214e51]/70 text-base leading-relaxed">
|
||||
Registreer je als{" "}
|
||||
<strong className="text-[#214e51]">artiest</strong> als je wil
|
||||
optreden, of als{" "}
|
||||
<strong className="text-[#214e51]">bezoeker</strong> als je wil
|
||||
komen kijken. Je kunt ook aangeven met hoeveel mensen je komt.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Step 2 */}
|
||||
<div className="flex flex-col gap-3 rounded-2xl border border-[#214e51]/15 bg-white p-6 shadow-sm">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-[#d82560] font-['Intro',sans-serif] font-bold text-lg text-white">
|
||||
2
|
||||
</div>
|
||||
<h3 className="font-['Intro',sans-serif] text-[#214e51] text-xl">
|
||||
Bevestig je plaats
|
||||
</h3>
|
||||
<p className="text-[#214e51]/70 text-base leading-relaxed">
|
||||
We vragen een bijdrage van{" "}
|
||||
<strong className="text-[#214e51]">€5 per inschrijving</strong> en{" "}
|
||||
<strong className="text-[#214e51]">€2 per extra persoon</strong>{" "}
|
||||
die je meebrengt.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Step 3 */}
|
||||
<div className="flex flex-col gap-3 rounded-2xl border border-[#214e51]/15 bg-white p-6 shadow-sm">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-[#d82560] font-['Intro',sans-serif] font-bold text-lg text-white">
|
||||
3
|
||||
</div>
|
||||
<h3 className="font-['Intro',sans-serif] text-[#214e51] text-xl">
|
||||
Geniet van de avond
|
||||
</h3>
|
||||
<p className="text-[#214e51]/70 text-base leading-relaxed">
|
||||
Je bijdrage gaat{" "}
|
||||
<strong className="text-[#214e51]">niet verloren</strong> — het
|
||||
wordt volledig op{" "}
|
||||
<strong className="text-[#214e51]">je drankkaart</strong> gezet.
|
||||
Zo kun je tijdens de avond iets drinken of een snack nemen.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Bottom note */}
|
||||
<p className="mt-8 max-w-3xl text-[#214e51]/60 text-base leading-relaxed">
|
||||
Zo zorgen we ervoor dat iedereen die zich inschrijft ook echt een
|
||||
plaats heeft — en dat we samen kunnen genieten van een gezellige,
|
||||
inspirerende avond vol muziek, poëzie en andere kunst.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import {
|
||||
inputCls,
|
||||
validateEmail,
|
||||
@@ -22,24 +23,16 @@ interface PerformerErrors {
|
||||
interface Props {
|
||||
onBack: () => void;
|
||||
onSuccess: (token: string, email: string, name: string) => void;
|
||||
prefillFirstName?: string;
|
||||
prefillLastName?: string;
|
||||
prefillEmail?: string;
|
||||
isLoggedIn?: boolean;
|
||||
}
|
||||
|
||||
export function PerformerForm({
|
||||
onBack,
|
||||
onSuccess,
|
||||
prefillFirstName = "",
|
||||
prefillLastName = "",
|
||||
prefillEmail = "",
|
||||
isLoggedIn = false,
|
||||
}: Props) {
|
||||
export function PerformerForm({ onBack, onSuccess }: Props) {
|
||||
const { data: session } = authClient.useSession();
|
||||
const sessionEmail = session?.user?.email ?? "";
|
||||
|
||||
const [data, setData] = useState({
|
||||
firstName: prefillFirstName,
|
||||
lastName: prefillLastName,
|
||||
email: prefillEmail,
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
artForm: "",
|
||||
experience: "",
|
||||
@@ -50,6 +43,12 @@ export function PerformerForm({
|
||||
const [errors, setErrors] = useState<PerformerErrors>({});
|
||||
const [touched, setTouched] = useState<Record<string, boolean>>({});
|
||||
|
||||
useEffect(() => {
|
||||
if (sessionEmail) {
|
||||
setData((prev) => ({ ...prev, email: sessionEmail }));
|
||||
}
|
||||
}, [sessionEmail]);
|
||||
|
||||
const submitMutation = useMutation({
|
||||
...orpc.submitRegistration.mutationOptions(),
|
||||
onSuccess: (result) => {
|
||||
@@ -265,15 +264,15 @@ export function PerformerForm({
|
||||
id="p-email"
|
||||
name="email"
|
||||
value={data.email}
|
||||
onChange={isLoggedIn ? undefined : handleChange}
|
||||
onBlur={isLoggedIn ? undefined : handleBlur}
|
||||
readOnly={isLoggedIn}
|
||||
onChange={sessionEmail ? undefined : handleChange}
|
||||
onBlur={sessionEmail ? undefined : handleBlur}
|
||||
readOnly={!!sessionEmail}
|
||||
placeholder="jouw@email.be"
|
||||
autoComplete="email"
|
||||
inputMode="email"
|
||||
aria-required="true"
|
||||
aria-invalid={touched.email && !!errors.email}
|
||||
className={`${inputCls(!!touched.email && !!errors.email)}${isLoggedIn ? "cursor-not-allowed opacity-60" : ""}`}
|
||||
className={`${inputCls(!!touched.email && !!errors.email)}${sessionEmail ? "cursor-not-allowed opacity-75" : ""}`}
|
||||
/>
|
||||
{touched.email && errors.email && (
|
||||
<span className="text-red-300 text-sm" role="alert">
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
import { useState } from "react";
|
||||
|
||||
interface Props {
|
||||
token: string;
|
||||
email?: string;
|
||||
name?: string;
|
||||
onReset: () => void;
|
||||
}
|
||||
|
||||
export function SuccessScreen({ token, email, name, onReset }: Props) {
|
||||
const manageUrl =
|
||||
typeof window !== "undefined"
|
||||
? `${window.location.origin}/manage/${token}`
|
||||
: `/manage/${token}`;
|
||||
|
||||
const [drinkkaartPromptDismissed, setDrinkkaartPromptDismissed] = useState(
|
||||
() => {
|
||||
try {
|
||||
return (
|
||||
typeof localStorage !== "undefined" &&
|
||||
localStorage.getItem("drinkkaart_prompt_dismissed") === "1"
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const handleDismissPrompt = () => {
|
||||
try {
|
||||
localStorage.setItem("drinkkaart_prompt_dismissed", "1");
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
setDrinkkaartPromptDismissed(true);
|
||||
};
|
||||
|
||||
// Build signup URL with pre-filled email query param so /login can pre-fill
|
||||
const signupUrl = email
|
||||
? `/login?signup=1&email=${encodeURIComponent(email)}`
|
||||
: "/login?signup=1";
|
||||
|
||||
return (
|
||||
<section
|
||||
id="registration"
|
||||
className="relative z-30 flex w-full items-center justify-center bg-[#214e51]/96 px-6 py-16 md:px-12"
|
||||
>
|
||||
<div className="mx-auto w-full max-w-3xl">
|
||||
<div className="rounded-lg border border-white/20 bg-white/5 p-8 md:p-12">
|
||||
<div className="mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-green-500/20 text-green-400">
|
||||
<svg
|
||||
className="h-8 w-8"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
strokeWidth={2}
|
||||
aria-label="Succes"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
d="M5 13l4 4L19 7"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<h2 className="mb-4 font-['Intro',sans-serif] text-3xl text-white md:text-4xl">
|
||||
Gelukt!
|
||||
</h2>
|
||||
<p className="mb-6 text-lg text-white/80">
|
||||
Je inschrijving is bevestigd. We sturen je zo dadelijk een
|
||||
bevestigingsmail.
|
||||
</p>
|
||||
<div className="mb-8 rounded-lg border border-white/10 bg-white/5 p-6">
|
||||
<p className="mb-2 text-sm text-white/60">
|
||||
Geen mail ontvangen? Gebruik deze link:
|
||||
</p>
|
||||
<a
|
||||
href={manageUrl}
|
||||
className="break-all text-sm text-white/80 underline underline-offset-2 hover:text-white"
|
||||
>
|
||||
{manageUrl}
|
||||
</a>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<a
|
||||
href={manageUrl}
|
||||
className="inline-flex items-center bg-white px-6 py-3 font-['Intro',sans-serif] text-[#214e51] text-lg transition-all hover:scale-105 hover:bg-gray-100"
|
||||
>
|
||||
Bekijk mijn inschrijving
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onReset}
|
||||
className="text-white/60 underline underline-offset-2 transition-colors hover:text-white"
|
||||
>
|
||||
Nog een inschrijving
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Account creation prompt */}
|
||||
{!drinkkaartPromptDismissed && (
|
||||
<div className="mt-8 rounded-xl border border-teal-400/30 bg-teal-400/10 p-6">
|
||||
<h3 className="mb-1 font-['Intro',sans-serif] text-lg text-white">
|
||||
Maak een gratis account aan
|
||||
</h3>
|
||||
<p className="mb-4 text-sm text-white/70">
|
||||
Met een account zie je je inschrijving, activeer je je
|
||||
Drinkkaart en laad je saldo op vóór het evenement.
|
||||
</p>
|
||||
<ul className="mb-5 space-y-1.5 text-sm text-white/70">
|
||||
<li className="flex items-center gap-2">
|
||||
<span className="text-teal-300">✓</span>
|
||||
Beheer je inschrijving op één plek
|
||||
</li>
|
||||
<li className="flex items-center gap-2">
|
||||
<span className="text-teal-300">✓</span>
|
||||
Digitale Drinkkaart met QR-code
|
||||
</li>
|
||||
<li className="flex items-center gap-2">
|
||||
<span className="text-teal-300">✓</span>
|
||||
Saldo opladen vóór het evenement
|
||||
</li>
|
||||
</ul>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<a
|
||||
href={signupUrl}
|
||||
className="inline-flex items-center rounded-lg bg-white px-5 py-2.5 font-['Intro',sans-serif] text-[#214e51] text-sm transition-all hover:scale-105 hover:bg-gray-100"
|
||||
>
|
||||
Account aanmaken
|
||||
{name && (
|
||||
<span className="ml-1.5 font-normal text-xs opacity-60">
|
||||
als {name}
|
||||
</span>
|
||||
)}
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDismissPrompt}
|
||||
className="text-sm text-white/40 underline underline-offset-2 transition-colors hover:text-white/70"
|
||||
>
|
||||
Overslaan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import {
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
validatePhone,
|
||||
validateTextField,
|
||||
} from "@/lib/registration";
|
||||
import { client, orpc } from "@/utils/orpc";
|
||||
import { orpc } from "@/utils/orpc";
|
||||
import { GiftSelector } from "./GiftSelector";
|
||||
import { GuestList } from "./GuestList";
|
||||
|
||||
@@ -25,231 +25,19 @@ interface WatcherErrors {
|
||||
|
||||
interface Props {
|
||||
onBack: () => void;
|
||||
prefillFirstName?: string;
|
||||
prefillLastName?: string;
|
||||
prefillEmail?: string;
|
||||
isLoggedIn?: boolean;
|
||||
}
|
||||
|
||||
// ── Account creation modal shown after successful registration ─────────────
|
||||
|
||||
interface AccountModalProps {
|
||||
prefillName: string;
|
||||
prefillEmail: string;
|
||||
onDone: () => void;
|
||||
}
|
||||
|
||||
function AccountModal({
|
||||
prefillName,
|
||||
prefillEmail,
|
||||
onDone,
|
||||
}: AccountModalProps) {
|
||||
const [name, setName] = useState(prefillName);
|
||||
const [email] = useState(prefillEmail); // email is fixed (tied to registration)
|
||||
const [password, setPassword] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [passwordError, setPasswordError] = useState<string | undefined>();
|
||||
|
||||
const signupMutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (password.length < 8)
|
||||
throw new Error("Wachtwoord moet minstens 8 tekens zijn");
|
||||
if (password !== confirmPassword)
|
||||
throw new Error("Wachtwoorden komen niet overeen");
|
||||
const result = await authClient.signUp.email({ email, password, name });
|
||||
if (result.error) throw new Error(result.error.message);
|
||||
return result.data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success(
|
||||
"Account aangemaakt! Je wordt nu doorgestuurd naar betaling.",
|
||||
);
|
||||
onDone();
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(`Account aanmaken mislukt: ${error.message}`);
|
||||
},
|
||||
});
|
||||
|
||||
const handlePasswordChange = (val: string) => {
|
||||
setPassword(val);
|
||||
if (passwordError) setPasswordError(undefined);
|
||||
};
|
||||
|
||||
const handleConfirmChange = (val: string) => {
|
||||
setConfirmPassword(val);
|
||||
if (passwordError) setPasswordError(undefined);
|
||||
};
|
||||
|
||||
const handleSignup = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (password.length < 8) {
|
||||
setPasswordError("Wachtwoord moet minstens 8 tekens zijn");
|
||||
return;
|
||||
}
|
||||
if (password !== confirmPassword) {
|
||||
setPasswordError("Wachtwoorden komen niet overeen");
|
||||
return;
|
||||
}
|
||||
signupMutation.mutate();
|
||||
};
|
||||
|
||||
// Receive the checkout URL from parent by exposing a setter via ref pattern
|
||||
// (simpler: the parent renders the modal and passes a prop)
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 px-4">
|
||||
<div className="w-full max-w-md rounded-2xl border border-white/10 bg-[#1a3d40] p-8 shadow-2xl">
|
||||
{/* Header */}
|
||||
<div className="mb-6 flex items-start gap-4">
|
||||
<div className="flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-teal-400/20 text-teal-300 text-xl">
|
||||
✓
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="font-['Intro',sans-serif] text-2xl text-white">
|
||||
Inschrijving gelukt!
|
||||
</h2>
|
||||
<p className="mt-1 text-sm text-white/60">
|
||||
Maak een gratis account aan om je Drinkkaart bij te houden.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Value prop */}
|
||||
<div className="mb-6 rounded-lg border border-teal-400/20 bg-teal-400/10 p-4">
|
||||
<ul className="space-y-1.5 text-sm text-white/80">
|
||||
<li className="flex items-center gap-2">
|
||||
<span className="text-teal-300">✓</span>
|
||||
Zie je drinkkaart-saldo en QR-code
|
||||
</li>
|
||||
<li className="flex items-center gap-2">
|
||||
<span className="text-teal-300">✓</span>
|
||||
Laad je kaart op vóór het evenement
|
||||
</li>
|
||||
<li className="flex items-center gap-2">
|
||||
<span className="text-teal-300">✓</span>
|
||||
Beheer je inschrijving op één plek
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Signup form */}
|
||||
<form onSubmit={handleSignup} className="space-y-4">
|
||||
{/* Name */}
|
||||
<div>
|
||||
<label
|
||||
className="mb-1.5 block text-sm text-white/60"
|
||||
htmlFor="modal-name"
|
||||
>
|
||||
Naam
|
||||
</label>
|
||||
<input
|
||||
id="modal-name"
|
||||
type="text"
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
required
|
||||
className="w-full rounded-lg border border-white/20 bg-white/10 px-3 py-2 text-white placeholder:text-white/30 focus:border-teal-400/60 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Email (read-only) */}
|
||||
<div>
|
||||
<label
|
||||
className="mb-1.5 block text-sm text-white/60"
|
||||
htmlFor="modal-email"
|
||||
>
|
||||
Email
|
||||
</label>
|
||||
<input
|
||||
id="modal-email"
|
||||
type="email"
|
||||
value={email}
|
||||
readOnly
|
||||
className="w-full cursor-not-allowed rounded-lg border border-white/10 bg-white/5 px-3 py-2 text-white/60"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Password */}
|
||||
<div>
|
||||
<label
|
||||
className="mb-1.5 block text-sm text-white/60"
|
||||
htmlFor="modal-password"
|
||||
>
|
||||
Wachtwoord
|
||||
</label>
|
||||
<input
|
||||
id="modal-password"
|
||||
type="password"
|
||||
placeholder="Minstens 8 tekens"
|
||||
value={password}
|
||||
onChange={(e) => handlePasswordChange(e.target.value)}
|
||||
required
|
||||
minLength={8}
|
||||
className="w-full rounded-lg border border-white/20 bg-white/10 px-3 py-2 text-white placeholder:text-white/30 focus:border-teal-400/60 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Confirm password */}
|
||||
<div>
|
||||
<label
|
||||
className="mb-1.5 block text-sm text-white/60"
|
||||
htmlFor="modal-confirm"
|
||||
>
|
||||
Bevestig wachtwoord
|
||||
</label>
|
||||
<input
|
||||
id="modal-confirm"
|
||||
type="password"
|
||||
placeholder="Herhaal je wachtwoord"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => handleConfirmChange(e.target.value)}
|
||||
required
|
||||
className="w-full rounded-lg border border-white/20 bg-white/10 px-3 py-2 text-white placeholder:text-white/30 focus:border-teal-400/60 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{passwordError && (
|
||||
<p className="text-red-300 text-sm">{passwordError}</p>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={signupMutation.isPending}
|
||||
className="w-full rounded-lg bg-white py-3 font-['Intro',sans-serif] text-[#214e51] transition-all hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
{signupMutation.isPending
|
||||
? "Bezig..."
|
||||
: "Account aanmaken & betalen"}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{/* Skip */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onDone}
|
||||
className="mt-4 w-full text-center text-sm text-white/40 transition-colors hover:text-white/70"
|
||||
>
|
||||
Overslaan, verder naar betaling →
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
onSuccess: (token: string, email: string, name: string) => void;
|
||||
}
|
||||
|
||||
// ── Main watcher form ──────────────────────────────────────────────────────
|
||||
|
||||
export function WatcherForm({
|
||||
onBack,
|
||||
prefillFirstName = "",
|
||||
prefillLastName = "",
|
||||
prefillEmail = "",
|
||||
isLoggedIn = false,
|
||||
}: Props) {
|
||||
export function WatcherForm({ onBack, onSuccess }: Props) {
|
||||
const { data: session } = authClient.useSession();
|
||||
const sessionEmail = session?.user?.email ?? "";
|
||||
|
||||
const [data, setData] = useState({
|
||||
firstName: prefillFirstName,
|
||||
lastName: prefillLastName,
|
||||
email: prefillEmail,
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
extraQuestions: "",
|
||||
});
|
||||
@@ -259,40 +47,21 @@ export function WatcherForm({
|
||||
const [guestErrors, setGuestErrors] = useState<GuestErrors[]>([]);
|
||||
const [giftAmount, setGiftAmount] = useState(0);
|
||||
|
||||
// Modal state: shown after successful registration while we fetch checkout URL
|
||||
const [modalState, setModalState] = useState<{
|
||||
prefillName: string;
|
||||
prefillEmail: string;
|
||||
checkoutUrl: string;
|
||||
} | null>(null);
|
||||
useEffect(() => {
|
||||
if (sessionEmail) {
|
||||
setData((prev) => ({ ...prev, email: sessionEmail }));
|
||||
}
|
||||
}, [sessionEmail]);
|
||||
|
||||
const submitMutation = useMutation({
|
||||
...orpc.submitRegistration.mutationOptions(),
|
||||
onSuccess: async (result) => {
|
||||
if (!result.managementToken) return;
|
||||
try {
|
||||
const redirectUrl = isLoggedIn
|
||||
? `${window.location.origin}/account?topup=success`
|
||||
: undefined;
|
||||
const checkout = await client.getCheckoutUrl({
|
||||
token: result.managementToken,
|
||||
redirectUrl,
|
||||
});
|
||||
if (isLoggedIn) {
|
||||
// Already logged in — skip the account-creation modal, go straight to checkout
|
||||
window.location.href = checkout.checkoutUrl;
|
||||
} else {
|
||||
// Show the account-creation modal before redirecting to checkout
|
||||
setModalState({
|
||||
prefillName:
|
||||
`${data.firstName.trim()} ${data.lastName.trim()}`.trim(),
|
||||
prefillEmail: data.email.trim(),
|
||||
checkoutUrl: checkout.checkoutUrl,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Checkout error:", error);
|
||||
toast.error("Er is iets misgegaan bij het aanmaken van de betaling");
|
||||
onSuccess: (result) => {
|
||||
if (result.managementToken) {
|
||||
onSuccess(
|
||||
result.managementToken,
|
||||
data.email.trim(),
|
||||
`${data.firstName.trim()} ${data.lastName.trim()}`.trim(),
|
||||
);
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -402,19 +171,6 @@ export function WatcherForm({
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Account-creation interstitial modal */}
|
||||
{modalState && (
|
||||
<AccountModal
|
||||
prefillName={modalState.prefillName}
|
||||
prefillEmail={modalState.prefillEmail}
|
||||
onDone={() => {
|
||||
const url = modalState.checkoutUrl;
|
||||
setModalState(null);
|
||||
window.location.href = url;
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Back + type header */}
|
||||
<div className="mb-8 flex items-center gap-4">
|
||||
<button
|
||||
@@ -544,15 +300,15 @@ export function WatcherForm({
|
||||
id="w-email"
|
||||
name="email"
|
||||
value={data.email}
|
||||
onChange={isLoggedIn ? undefined : handleChange}
|
||||
onBlur={isLoggedIn ? undefined : handleBlur}
|
||||
readOnly={isLoggedIn}
|
||||
onChange={sessionEmail ? undefined : handleChange}
|
||||
onBlur={sessionEmail ? undefined : handleBlur}
|
||||
readOnly={!!sessionEmail}
|
||||
placeholder="jouw@email.be"
|
||||
autoComplete="email"
|
||||
inputMode="email"
|
||||
aria-required="true"
|
||||
aria-invalid={touched.email && !!errors.email}
|
||||
className={`${inputCls(!!touched.email && !!errors.email)}${isLoggedIn ? "cursor-not-allowed opacity-60" : ""}`}
|
||||
className={`${inputCls(!!touched.email && !!errors.email)}${sessionEmail ? "cursor-not-allowed opacity-75" : ""}`}
|
||||
/>
|
||||
{touched.email && errors.email && (
|
||||
<span className="text-red-300 text-sm" role="alert">
|
||||
@@ -653,7 +409,7 @@ export function WatcherForm({
|
||||
Bezig...
|
||||
</span>
|
||||
) : (
|
||||
"Bevestigen & betalen"
|
||||
"Bevestigen"
|
||||
)}
|
||||
</button>
|
||||
<a
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
|
||||
export const authClient = createAuthClient({});
|
||||
export const authClient = createAuthClient();
|
||||
|
||||
5
apps/web/src/lib/opening.ts
Normal file
5
apps/web/src/lib/opening.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Single source-of-truth for when registration opens.
|
||||
* Change this date to reschedule — all gating logic imports from here.
|
||||
*/
|
||||
export const REGISTRATION_OPENS_AT = new Date("2026-03-16T19:00:00+01:00");
|
||||
45
apps/web/src/lib/useRegistrationOpen.ts
Normal file
45
apps/web/src/lib/useRegistrationOpen.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { REGISTRATION_OPENS_AT } from "./opening";
|
||||
|
||||
interface RegistrationOpenState {
|
||||
isOpen: boolean;
|
||||
days: number;
|
||||
hours: number;
|
||||
minutes: number;
|
||||
seconds: number;
|
||||
}
|
||||
|
||||
function compute(): RegistrationOpenState {
|
||||
const diff = REGISTRATION_OPENS_AT.getTime() - Date.now();
|
||||
if (diff <= 0) {
|
||||
return { isOpen: true, days: 0, hours: 0, minutes: 0, seconds: 0 };
|
||||
}
|
||||
const totalSeconds = Math.floor(diff / 1000);
|
||||
const days = Math.floor(totalSeconds / 86400);
|
||||
const hours = Math.floor((totalSeconds % 86400) / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
return { isOpen: false, days, hours, minutes, seconds };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns live countdown state to {@link REGISTRATION_OPENS_AT}.
|
||||
* Ticks every second; clears the interval once registration is open.
|
||||
*/
|
||||
export function useRegistrationOpen(): RegistrationOpenState {
|
||||
const [state, setState] = useState<RegistrationOpenState>(compute);
|
||||
|
||||
useEffect(() => {
|
||||
if (state.isOpen) return;
|
||||
|
||||
const id = setInterval(() => {
|
||||
const next = compute();
|
||||
setState(next);
|
||||
if (next.isOpen) clearInterval(id);
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(id);
|
||||
}, [state.isOpen]);
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -10,8 +10,10 @@
|
||||
|
||||
import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as TermsRouteImport } from './routes/terms'
|
||||
import { Route as ResetPasswordRouteImport } from './routes/reset-password'
|
||||
import { Route as PrivacyRouteImport } from './routes/privacy'
|
||||
import { Route as LoginRouteImport } from './routes/login'
|
||||
import { Route as ForgotPasswordRouteImport } from './routes/forgot-password'
|
||||
import { Route as DrinkkaartRouteImport } from './routes/drinkkaart'
|
||||
import { Route as ContactRouteImport } from './routes/contact'
|
||||
import { Route as AccountRouteImport } from './routes/account'
|
||||
@@ -21,6 +23,7 @@ import { Route as ManageTokenRouteImport } from './routes/manage.$token'
|
||||
import { Route as AdminDrinkkaartRouteImport } from './routes/admin/drinkkaart'
|
||||
import { Route as ApiWebhookMollieRouteImport } from './routes/api/webhook/mollie'
|
||||
import { Route as ApiRpcSplatRouteImport } from './routes/api/rpc/$'
|
||||
import { Route as ApiCronRemindersRouteImport } from './routes/api/cron/reminders'
|
||||
import { Route as ApiAuthSplatRouteImport } from './routes/api/auth/$'
|
||||
|
||||
const TermsRoute = TermsRouteImport.update({
|
||||
@@ -28,6 +31,11 @@ const TermsRoute = TermsRouteImport.update({
|
||||
path: '/terms',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ResetPasswordRoute = ResetPasswordRouteImport.update({
|
||||
id: '/reset-password',
|
||||
path: '/reset-password',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const PrivacyRoute = PrivacyRouteImport.update({
|
||||
id: '/privacy',
|
||||
path: '/privacy',
|
||||
@@ -38,6 +46,11 @@ const LoginRoute = LoginRouteImport.update({
|
||||
path: '/login',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ForgotPasswordRoute = ForgotPasswordRouteImport.update({
|
||||
id: '/forgot-password',
|
||||
path: '/forgot-password',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const DrinkkaartRoute = DrinkkaartRouteImport.update({
|
||||
id: '/drinkkaart',
|
||||
path: '/drinkkaart',
|
||||
@@ -83,6 +96,11 @@ const ApiRpcSplatRoute = ApiRpcSplatRouteImport.update({
|
||||
path: '/api/rpc/$',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ApiCronRemindersRoute = ApiCronRemindersRouteImport.update({
|
||||
id: '/api/cron/reminders',
|
||||
path: '/api/cron/reminders',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ApiAuthSplatRoute = ApiAuthSplatRouteImport.update({
|
||||
id: '/api/auth/$',
|
||||
path: '/api/auth/$',
|
||||
@@ -94,13 +112,16 @@ export interface FileRoutesByFullPath {
|
||||
'/account': typeof AccountRoute
|
||||
'/contact': typeof ContactRoute
|
||||
'/drinkkaart': typeof DrinkkaartRoute
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/privacy': typeof PrivacyRoute
|
||||
'/reset-password': typeof ResetPasswordRoute
|
||||
'/terms': typeof TermsRoute
|
||||
'/admin/drinkkaart': typeof AdminDrinkkaartRoute
|
||||
'/manage/$token': typeof ManageTokenRoute
|
||||
'/admin/': typeof AdminIndexRoute
|
||||
'/api/auth/$': typeof ApiAuthSplatRoute
|
||||
'/api/cron/reminders': typeof ApiCronRemindersRoute
|
||||
'/api/rpc/$': typeof ApiRpcSplatRoute
|
||||
'/api/webhook/mollie': typeof ApiWebhookMollieRoute
|
||||
}
|
||||
@@ -109,13 +130,16 @@ export interface FileRoutesByTo {
|
||||
'/account': typeof AccountRoute
|
||||
'/contact': typeof ContactRoute
|
||||
'/drinkkaart': typeof DrinkkaartRoute
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/privacy': typeof PrivacyRoute
|
||||
'/reset-password': typeof ResetPasswordRoute
|
||||
'/terms': typeof TermsRoute
|
||||
'/admin/drinkkaart': typeof AdminDrinkkaartRoute
|
||||
'/manage/$token': typeof ManageTokenRoute
|
||||
'/admin': typeof AdminIndexRoute
|
||||
'/api/auth/$': typeof ApiAuthSplatRoute
|
||||
'/api/cron/reminders': typeof ApiCronRemindersRoute
|
||||
'/api/rpc/$': typeof ApiRpcSplatRoute
|
||||
'/api/webhook/mollie': typeof ApiWebhookMollieRoute
|
||||
}
|
||||
@@ -125,13 +149,16 @@ export interface FileRoutesById {
|
||||
'/account': typeof AccountRoute
|
||||
'/contact': typeof ContactRoute
|
||||
'/drinkkaart': typeof DrinkkaartRoute
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/privacy': typeof PrivacyRoute
|
||||
'/reset-password': typeof ResetPasswordRoute
|
||||
'/terms': typeof TermsRoute
|
||||
'/admin/drinkkaart': typeof AdminDrinkkaartRoute
|
||||
'/manage/$token': typeof ManageTokenRoute
|
||||
'/admin/': typeof AdminIndexRoute
|
||||
'/api/auth/$': typeof ApiAuthSplatRoute
|
||||
'/api/cron/reminders': typeof ApiCronRemindersRoute
|
||||
'/api/rpc/$': typeof ApiRpcSplatRoute
|
||||
'/api/webhook/mollie': typeof ApiWebhookMollieRoute
|
||||
}
|
||||
@@ -142,13 +169,16 @@ export interface FileRouteTypes {
|
||||
| '/account'
|
||||
| '/contact'
|
||||
| '/drinkkaart'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/privacy'
|
||||
| '/reset-password'
|
||||
| '/terms'
|
||||
| '/admin/drinkkaart'
|
||||
| '/manage/$token'
|
||||
| '/admin/'
|
||||
| '/api/auth/$'
|
||||
| '/api/cron/reminders'
|
||||
| '/api/rpc/$'
|
||||
| '/api/webhook/mollie'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
@@ -157,13 +187,16 @@ export interface FileRouteTypes {
|
||||
| '/account'
|
||||
| '/contact'
|
||||
| '/drinkkaart'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/privacy'
|
||||
| '/reset-password'
|
||||
| '/terms'
|
||||
| '/admin/drinkkaart'
|
||||
| '/manage/$token'
|
||||
| '/admin'
|
||||
| '/api/auth/$'
|
||||
| '/api/cron/reminders'
|
||||
| '/api/rpc/$'
|
||||
| '/api/webhook/mollie'
|
||||
id:
|
||||
@@ -172,13 +205,16 @@ export interface FileRouteTypes {
|
||||
| '/account'
|
||||
| '/contact'
|
||||
| '/drinkkaart'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/privacy'
|
||||
| '/reset-password'
|
||||
| '/terms'
|
||||
| '/admin/drinkkaart'
|
||||
| '/manage/$token'
|
||||
| '/admin/'
|
||||
| '/api/auth/$'
|
||||
| '/api/cron/reminders'
|
||||
| '/api/rpc/$'
|
||||
| '/api/webhook/mollie'
|
||||
fileRoutesById: FileRoutesById
|
||||
@@ -188,13 +224,16 @@ export interface RootRouteChildren {
|
||||
AccountRoute: typeof AccountRoute
|
||||
ContactRoute: typeof ContactRoute
|
||||
DrinkkaartRoute: typeof DrinkkaartRoute
|
||||
ForgotPasswordRoute: typeof ForgotPasswordRoute
|
||||
LoginRoute: typeof LoginRoute
|
||||
PrivacyRoute: typeof PrivacyRoute
|
||||
ResetPasswordRoute: typeof ResetPasswordRoute
|
||||
TermsRoute: typeof TermsRoute
|
||||
AdminDrinkkaartRoute: typeof AdminDrinkkaartRoute
|
||||
ManageTokenRoute: typeof ManageTokenRoute
|
||||
AdminIndexRoute: typeof AdminIndexRoute
|
||||
ApiAuthSplatRoute: typeof ApiAuthSplatRoute
|
||||
ApiCronRemindersRoute: typeof ApiCronRemindersRoute
|
||||
ApiRpcSplatRoute: typeof ApiRpcSplatRoute
|
||||
ApiWebhookMollieRoute: typeof ApiWebhookMollieRoute
|
||||
}
|
||||
@@ -208,6 +247,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof TermsRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/reset-password': {
|
||||
id: '/reset-password'
|
||||
path: '/reset-password'
|
||||
fullPath: '/reset-password'
|
||||
preLoaderRoute: typeof ResetPasswordRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/privacy': {
|
||||
id: '/privacy'
|
||||
path: '/privacy'
|
||||
@@ -222,6 +268,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof LoginRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/forgot-password': {
|
||||
id: '/forgot-password'
|
||||
path: '/forgot-password'
|
||||
fullPath: '/forgot-password'
|
||||
preLoaderRoute: typeof ForgotPasswordRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/drinkkaart': {
|
||||
id: '/drinkkaart'
|
||||
path: '/drinkkaart'
|
||||
@@ -285,6 +338,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiRpcSplatRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/api/cron/reminders': {
|
||||
id: '/api/cron/reminders'
|
||||
path: '/api/cron/reminders'
|
||||
fullPath: '/api/cron/reminders'
|
||||
preLoaderRoute: typeof ApiCronRemindersRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/api/auth/$': {
|
||||
id: '/api/auth/$'
|
||||
path: '/api/auth/$'
|
||||
@@ -300,13 +360,16 @@ const rootRouteChildren: RootRouteChildren = {
|
||||
AccountRoute: AccountRoute,
|
||||
ContactRoute: ContactRoute,
|
||||
DrinkkaartRoute: DrinkkaartRoute,
|
||||
ForgotPasswordRoute: ForgotPasswordRoute,
|
||||
LoginRoute: LoginRoute,
|
||||
PrivacyRoute: PrivacyRoute,
|
||||
ResetPasswordRoute: ResetPasswordRoute,
|
||||
TermsRoute: TermsRoute,
|
||||
AdminDrinkkaartRoute: AdminDrinkkaartRoute,
|
||||
ManageTokenRoute: ManageTokenRoute,
|
||||
AdminIndexRoute: AdminIndexRoute,
|
||||
ApiAuthSplatRoute: ApiAuthSplatRoute,
|
||||
ApiCronRemindersRoute: ApiCronRemindersRoute,
|
||||
ApiRpcSplatRoute: ApiRpcSplatRoute,
|
||||
ApiWebhookMollieRoute: ApiWebhookMollieRoute,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { EmailMessage } from "@kk/api/email-queue";
|
||||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
import { createRouter as createTanStackRouter } from "@tanstack/react-router";
|
||||
|
||||
@@ -6,6 +7,18 @@ import Loader from "./components/loader";
|
||||
import { routeTree } from "./routeTree.gen";
|
||||
import { orpc, queryClient } from "./utils/orpc";
|
||||
|
||||
// Minimal CF Queue binding shape needed for type inference
|
||||
type Queue = {
|
||||
send(
|
||||
message: EmailMessage,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
sendBatch(
|
||||
messages: Array<{ body: EmailMessage }>,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
export const getRouter = () => {
|
||||
const router = createTanStackRouter({
|
||||
routeTree,
|
||||
@@ -26,3 +39,9 @@ declare module "@tanstack/react-router" {
|
||||
router: ReturnType<typeof getRouter>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "@tanstack/router-core" {
|
||||
interface Register {
|
||||
server: { requestContext: { emailQueue?: Queue } };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export const Route = createRootRouteWithContext<RouterAppContext>()({
|
||||
price: "0",
|
||||
priceCurrency: "EUR",
|
||||
availability: "https://schema.org/InStock",
|
||||
validFrom: "2026-03-01T00:00:00+02:00",
|
||||
validFrom: "2026-03-16T19:00:00+01:00",
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
|
||||
import {
|
||||
Calendar,
|
||||
@@ -74,6 +74,22 @@ function AccountPage() {
|
||||
const [showQr, setShowQr] = useState(false);
|
||||
const [showTopUp, setShowTopUp] = useState(false);
|
||||
|
||||
const checkoutMutation = useMutation({
|
||||
mutationFn: async (token: string) => {
|
||||
const result = await client.getCheckoutUrl({
|
||||
token,
|
||||
redirectUrl: `${window.location.origin}/account?topup=success`,
|
||||
});
|
||||
return result;
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
window.location.href = data.checkoutUrl;
|
||||
},
|
||||
onError: () => {
|
||||
toast.error("Er is iets misgegaan bij het aanmaken van de betaling");
|
||||
},
|
||||
});
|
||||
|
||||
const sessionQuery = useQuery({
|
||||
queryKey: ["session"],
|
||||
queryFn: () => authClient.getSession(),
|
||||
@@ -187,7 +203,13 @@ function AccountPage() {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<PaymentBadge status={registration.paymentStatus} />
|
||||
{/* Only show a payment badge when there's actually something to pay:
|
||||
watchers always have a drinkcard fee; anyone with a gift amount does too.
|
||||
Performers with no gift have nothing to pay → hide the badge. */}
|
||||
{(registration.registrationType === "watcher" ||
|
||||
(registration.giftAmount ?? 0) > 0) && (
|
||||
<PaymentBadge status={registration.paymentStatus} />
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Name */}
|
||||
@@ -276,6 +298,60 @@ function AccountPage() {
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Pay now CTA — shown for watchers with pending payment */}
|
||||
{registration.registrationType === "watcher" &&
|
||||
registration.paymentStatus === "pending" &&
|
||||
registration.managementToken && (
|
||||
<div className="mt-5 rounded-lg border border-teal-400/30 bg-teal-400/10 p-4">
|
||||
<p className="mb-3 text-sm text-white/80">
|
||||
Je inschrijving is bevestigd maar de betaling staat nog
|
||||
open. Betaal nu om je Drinkkaart te activeren.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
disabled={checkoutMutation.isPending}
|
||||
onClick={() =>
|
||||
checkoutMutation.mutate(
|
||||
registration.managementToken ?? "",
|
||||
)
|
||||
}
|
||||
className="inline-flex items-center gap-2 rounded-lg bg-white px-4 py-2 font-semibold text-[#214e51] text-sm transition-colors hover:bg-white/90 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
{checkoutMutation.isPending ? (
|
||||
<>
|
||||
<svg
|
||||
className="h-4 w-4 animate-spin"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<circle
|
||||
className="opacity-25"
|
||||
cx="12"
|
||||
cy="12"
|
||||
r="10"
|
||||
stroke="currentColor"
|
||||
strokeWidth="4"
|
||||
/>
|
||||
<path
|
||||
className="opacity-75"
|
||||
fill="currentColor"
|
||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
||||
/>
|
||||
</svg>
|
||||
Laden...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Wallet className="h-4 w-4" />
|
||||
Betaal nu
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="rounded-2xl border border-white/10 bg-white/5 p-6">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
40
apps/web/src/routes/api/cron/reminders.ts
Normal file
40
apps/web/src/routes/api/cron/reminders.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { runSendReminders } from "@kk/api/routers/index";
|
||||
import { env } from "@kk/env/server";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
async function handleCronReminders({ request }: { request: Request }) {
|
||||
const secret = env.CRON_SECRET;
|
||||
if (!secret) {
|
||||
return new Response("CRON_SECRET not configured", { status: 500 });
|
||||
}
|
||||
|
||||
// Accept the secret via Authorization header (Bearer) or JSON body
|
||||
const authHeader = request.headers.get("Authorization");
|
||||
let providedSecret: string | null = null;
|
||||
|
||||
if (authHeader?.startsWith("Bearer ")) {
|
||||
providedSecret = authHeader.slice(7);
|
||||
} else {
|
||||
try {
|
||||
const body = await request.json();
|
||||
providedSecret = (body as { secret?: string }).secret ?? null;
|
||||
} catch {
|
||||
// ignore parse errors
|
||||
}
|
||||
}
|
||||
|
||||
if (!providedSecret || providedSecret !== secret) {
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
|
||||
const result = await runSendReminders();
|
||||
return Response.json(result);
|
||||
}
|
||||
|
||||
export const Route = createFileRoute("/api/cron/reminders")({
|
||||
server: {
|
||||
handlers: {
|
||||
POST: handleCronReminders,
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createContext } from "@kk/api/context";
|
||||
import type { EmailMessage } from "@kk/api/email-queue";
|
||||
import { appRouter } from "@kk/api/routers/index";
|
||||
import { OpenAPIHandler } from "@orpc/openapi/fetch";
|
||||
import { OpenAPIReferencePlugin } from "@orpc/openapi/plugins";
|
||||
@@ -7,6 +8,18 @@ import { RPCHandler } from "@orpc/server/fetch";
|
||||
import { ZodToJsonSchemaConverter } from "@orpc/zod/zod4";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
// Minimal CF Queue binding shape — mirrors the declaration in router.tsx / context.ts
|
||||
type Queue = {
|
||||
send(
|
||||
message: EmailMessage,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
sendBatch(
|
||||
messages: Array<{ body: EmailMessage }>,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
const rpcHandler = new RPCHandler(appRouter, {
|
||||
interceptors: [
|
||||
onError((error) => {
|
||||
@@ -28,16 +41,21 @@ const apiHandler = new OpenAPIHandler(appRouter, {
|
||||
],
|
||||
});
|
||||
|
||||
async function handle({ request }: { request: Request }) {
|
||||
const rpcResult = await rpcHandler.handle(request, {
|
||||
async function handle(ctx: { request: Request; context?: unknown }) {
|
||||
// emailQueue is threaded in via the fetch wrapper in server.ts
|
||||
const emailQueue = (ctx.context as { emailQueue?: Queue } | undefined)
|
||||
?.emailQueue;
|
||||
const context = await createContext({ req: ctx.request, emailQueue });
|
||||
|
||||
const rpcResult = await rpcHandler.handle(ctx.request, {
|
||||
prefix: "/api/rpc",
|
||||
context: await createContext({ req: request }),
|
||||
context,
|
||||
});
|
||||
if (rpcResult.response) return rpcResult.response;
|
||||
|
||||
const apiResult = await apiHandler.handle(request, {
|
||||
const apiResult = await apiHandler.handle(ctx.request, {
|
||||
prefix: "/api/rpc/api-reference",
|
||||
context: await createContext({ req: request }),
|
||||
context,
|
||||
});
|
||||
if (apiResult.response) return apiResult.response;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { sendPaymentConfirmationEmail } from "@kk/api/email";
|
||||
import type { EmailMessage } from "@kk/api/email-queue";
|
||||
import { creditRegistrationToAccount } from "@kk/api/routers/index";
|
||||
import { db } from "@kk/db";
|
||||
import { drinkkaart, drinkkaartTopup, registration } from "@kk/db/schema";
|
||||
@@ -7,6 +9,14 @@ import { env } from "@kk/env/server";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
|
||||
// Minimal CF Queue binding shape used to enqueue emails
|
||||
type EmailQueue = {
|
||||
send(
|
||||
message: EmailMessage,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
// Mollie payment object (relevant fields only)
|
||||
interface MolliePayment {
|
||||
id: string;
|
||||
@@ -40,7 +50,15 @@ async function fetchMolliePayment(paymentId: string): Promise<MolliePayment> {
|
||||
return response.json() as Promise<MolliePayment>;
|
||||
}
|
||||
|
||||
async function handleWebhook({ request }: { request: Request }) {
|
||||
async function handleWebhook({
|
||||
request,
|
||||
context,
|
||||
}: {
|
||||
request: Request;
|
||||
context?: unknown;
|
||||
}) {
|
||||
const emailQueue = (context as { emailQueue?: EmailQueue } | undefined)
|
||||
?.emailQueue;
|
||||
if (!env.MOLLIE_API_KEY) {
|
||||
console.error("MOLLIE_API_KEY not configured");
|
||||
return new Response("Payment provider not configured", { status: 500 });
|
||||
@@ -206,6 +224,26 @@ async function handleWebhook({ request }: { request: Request }) {
|
||||
`Payment successful for registration ${registrationToken}, payment ${payment.id}`,
|
||||
);
|
||||
|
||||
// Send payment confirmation email via queue when available, otherwise direct.
|
||||
const confirmMsg: EmailMessage = {
|
||||
type: "paymentConfirmation",
|
||||
to: regRow.email,
|
||||
firstName: regRow.firstName,
|
||||
managementToken: regRow.managementToken ?? registrationToken,
|
||||
drinkCardValue: regRow.drinkCardValue ?? undefined,
|
||||
giftAmount: regRow.giftAmount ?? undefined,
|
||||
};
|
||||
if (emailQueue) {
|
||||
await emailQueue.send(confirmMsg);
|
||||
} else {
|
||||
sendPaymentConfirmationEmail(confirmMsg).catch((err) =>
|
||||
console.error(
|
||||
`Failed to send payment confirmation email for ${regRow.email}:`,
|
||||
err,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// If this is a watcher with a drink card value, try to credit their
|
||||
// drinkkaart immediately — but only if they already have an account.
|
||||
if (
|
||||
|
||||
118
apps/web/src/routes/forgot-password.tsx
Normal file
118
apps/web/src/routes/forgot-password.tsx
Normal file
@@ -0,0 +1,118 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
|
||||
export const Route = createFileRoute("/forgot-password")({
|
||||
component: ForgotPasswordPage,
|
||||
});
|
||||
|
||||
function ForgotPasswordPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [sent, setSent] = useState(false);
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async (email: string) => {
|
||||
const result = await authClient.requestPasswordReset({
|
||||
email,
|
||||
redirectTo: "/reset-password",
|
||||
});
|
||||
if (result.error) {
|
||||
throw new Error(result.error.message);
|
||||
}
|
||||
return result.data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
setSent(true);
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
mutation.mutate(email);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-[calc(100dvh-2.75rem)] items-center justify-center overflow-y-auto px-4 py-8 sm:min-h-[calc(100dvh-3.5rem)]">
|
||||
<Card className="my-auto w-full max-w-md border-white/10 bg-white/5">
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="font-['Intro',sans-serif] text-3xl text-white">
|
||||
Wachtwoord vergeten
|
||||
</CardTitle>
|
||||
<CardDescription className="text-white/60">
|
||||
{sent
|
||||
? "Controleer je inbox"
|
||||
: "Vul je e-mailadres in en we sturen je een link"}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{sent ? (
|
||||
<div className="space-y-4">
|
||||
<div className="rounded-lg border border-white/10 bg-white/5 p-5 text-center">
|
||||
<p className="text-sm text-white/80 leading-relaxed">
|
||||
Als er een account bestaat voor{" "}
|
||||
<span className="font-medium text-white">{email}</span>, is er
|
||||
een e-mail verstuurd met een link om je wachtwoord opnieuw in
|
||||
te stellen. De link is 1 uur geldig.
|
||||
</p>
|
||||
</div>
|
||||
<Link
|
||||
to="/login"
|
||||
className="block text-center text-sm text-white/60 hover:text-white"
|
||||
>
|
||||
← Terug naar inloggen
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label
|
||||
htmlFor="email"
|
||||
className="mb-2 block text-sm text-white/60"
|
||||
>
|
||||
E-mailadres
|
||||
</label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
placeholder="jouw@email.be"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
required
|
||||
className="border-white/20 bg-white/10 text-white placeholder:text-white/40"
|
||||
/>
|
||||
</div>
|
||||
{mutation.isError && (
|
||||
<p className="text-red-400 text-sm">{mutation.error.message}</p>
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={mutation.isPending}
|
||||
className="w-full bg-white text-[#214e51] hover:bg-white/90"
|
||||
>
|
||||
{mutation.isPending ? "Bezig..." : "Stuur reset-link"}
|
||||
</Button>
|
||||
<div className="text-center">
|
||||
<Link
|
||||
to="/login"
|
||||
className="text-sm text-white/60 hover:text-white"
|
||||
>
|
||||
← Terug naar inloggen
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
|
||||
import ArtForms from "@/components/homepage/ArtForms";
|
||||
import EventRegistrationForm from "@/components/homepage/EventRegistrationForm";
|
||||
import Footer from "@/components/homepage/Footer";
|
||||
import Hero from "@/components/homepage/Hero";
|
||||
import HoeInschrijven from "@/components/homepage/HoeInschrijven";
|
||||
import Info from "@/components/homepage/Info";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
@@ -16,7 +15,7 @@ function HomePage() {
|
||||
<main className="relative">
|
||||
<Hero />
|
||||
<Info />
|
||||
<ArtForms />
|
||||
<HoeInschrijven />
|
||||
<EventRegistrationForm />
|
||||
<Footer />
|
||||
</main>
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import { REGISTRATION_OPENS_AT } from "@/lib/opening";
|
||||
import { useRegistrationOpen } from "@/lib/useRegistrationOpen";
|
||||
import { orpc } from "@/utils/orpc";
|
||||
|
||||
export const Route = createFileRoute("/login")({
|
||||
@@ -31,6 +33,7 @@ export const Route = createFileRoute("/login")({
|
||||
function LoginPage() {
|
||||
const navigate = useNavigate();
|
||||
const search = Route.useSearch();
|
||||
const { isOpen } = useRegistrationOpen();
|
||||
const [isSignup, setIsSignup] = useState(() => search.signup === "1");
|
||||
const [email, setEmail] = useState(() => search.email ?? "");
|
||||
const [password, setPassword] = useState("");
|
||||
@@ -204,6 +207,43 @@ function LoginPage() {
|
||||
← Terug naar website
|
||||
</Link>
|
||||
</div>
|
||||
) : isSignup && !isOpen ? (
|
||||
/* Signup is closed until registration opens */
|
||||
<div className="space-y-4">
|
||||
<div className="rounded-lg border border-white/10 bg-white/5 p-5 text-center">
|
||||
<p className="mb-1 font-['Intro',sans-serif] text-white">
|
||||
Registratie nog niet open
|
||||
</p>
|
||||
<p className="text-sm text-white/60">
|
||||
Accounts aanmaken kan vanaf{" "}
|
||||
<span className="text-teal-300">
|
||||
{REGISTRATION_OPENS_AT.toLocaleDateString("nl-BE", {
|
||||
weekday: "long",
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
})}{" "}
|
||||
om{" "}
|
||||
{REGISTRATION_OPENS_AT.toLocaleTimeString("nl-BE", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})}
|
||||
</span>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsSignup(false)}
|
||||
className="text-sm text-white/60 hover:text-white"
|
||||
>
|
||||
Al een account? Log in
|
||||
</button>
|
||||
<Link to="/" className="text-sm text-white/60 hover:text-white">
|
||||
← Terug naar website
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
{isSignup && (
|
||||
@@ -259,6 +299,16 @@ function LoginPage() {
|
||||
className="border-white/20 bg-white/10 text-white placeholder:text-white/40"
|
||||
/>
|
||||
</div>
|
||||
{!isSignup && (
|
||||
<div className="text-right">
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
className="text-sm text-white/50 hover:text-white"
|
||||
>
|
||||
Wachtwoord vergeten?
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={loginMutation.isPending || signupMutation.isPending}
|
||||
@@ -271,15 +321,34 @@ function LoginPage() {
|
||||
: "Inloggen"}
|
||||
</Button>
|
||||
<div className="flex flex-col gap-2 text-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsSignup(!isSignup)}
|
||||
className="text-sm text-white/60 hover:text-white"
|
||||
>
|
||||
{isSignup
|
||||
? "Al een account? Log in"
|
||||
: "Nog geen account? Registreer"}
|
||||
</button>
|
||||
{/* Only show signup toggle when registration is open */}
|
||||
{isOpen && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsSignup(!isSignup)}
|
||||
className="text-sm text-white/60 hover:text-white"
|
||||
>
|
||||
{isSignup
|
||||
? "Al een account? Log in"
|
||||
: "Nog geen account? Registreer"}
|
||||
</button>
|
||||
)}
|
||||
{!isOpen && isSignup === false && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsSignup(true)}
|
||||
className="cursor-not-allowed text-sm text-white/30"
|
||||
disabled
|
||||
title={`Registratie opent op ${REGISTRATION_OPENS_AT.toLocaleString("nl-BE", { day: "numeric", month: "long", hour: "2-digit", minute: "2-digit" })}`}
|
||||
>
|
||||
Nog geen account? (opent{" "}
|
||||
{REGISTRATION_OPENS_AT.toLocaleString("nl-BE", {
|
||||
day: "numeric",
|
||||
month: "long",
|
||||
})}
|
||||
)
|
||||
</button>
|
||||
)}
|
||||
<Link to="/" className="text-sm text-white/60 hover:text-white">
|
||||
← Terug naar website
|
||||
</Link>
|
||||
|
||||
@@ -585,8 +585,10 @@ function ManageRegistrationPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Payment status - shown for everyone with pending/extra payment or gift */}
|
||||
{(data.paymentStatus !== "paid" || (data.giftAmount ?? 0) > 0) && (
|
||||
{/* Payment status badge:
|
||||
- performers only see a badge if they have a gift to pay, or already paid one
|
||||
- watchers always have a payment (drink card), so always show a badge */}
|
||||
{(isPerformer ? (data.giftAmount ?? 0) > 0 : true) && (
|
||||
<div className="mb-6">
|
||||
{data.paymentStatus === "paid" ? (
|
||||
<PaidBadge />
|
||||
|
||||
154
apps/web/src/routes/reset-password.tsx
Normal file
154
apps/web/src/routes/reset-password.tsx
Normal file
@@ -0,0 +1,154 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
|
||||
export const Route = createFileRoute("/reset-password")({
|
||||
validateSearch: (search: Record<string, unknown>) => {
|
||||
const token = typeof search.token === "string" ? search.token : undefined;
|
||||
return { ...(token !== undefined && { token }) } as { token?: string };
|
||||
},
|
||||
component: ResetPasswordPage,
|
||||
});
|
||||
|
||||
function ResetPasswordPage() {
|
||||
const navigate = useNavigate();
|
||||
const search = Route.useSearch();
|
||||
const token = search.token;
|
||||
|
||||
const [password, setPassword] = useState("");
|
||||
const [confirm, setConfirm] = useState("");
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async ({
|
||||
token,
|
||||
newPassword,
|
||||
}: {
|
||||
token: string;
|
||||
newPassword: string;
|
||||
}) => {
|
||||
const result = await authClient.resetPassword({ token, newPassword });
|
||||
if (result.error) {
|
||||
throw new Error(result.error.message);
|
||||
}
|
||||
return result.data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success("Wachtwoord succesvol gewijzigd!");
|
||||
navigate({ to: "/login" });
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (password !== confirm) {
|
||||
toast.error("De wachtwoorden komen niet overeen.");
|
||||
return;
|
||||
}
|
||||
if (!token) {
|
||||
toast.error("Ongeldige reset-link. Vraag een nieuwe aan.");
|
||||
return;
|
||||
}
|
||||
mutation.mutate({ token, newPassword: password });
|
||||
};
|
||||
|
||||
if (!token) {
|
||||
return (
|
||||
<div className="flex min-h-[calc(100dvh-2.75rem)] items-center justify-center px-4 sm:min-h-[calc(100dvh-3.5rem)]">
|
||||
<Card className="w-full max-w-md border-white/10 bg-white/5">
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="font-['Intro',sans-serif] text-3xl text-white">
|
||||
Ongeldige link
|
||||
</CardTitle>
|
||||
<CardDescription className="text-white/60">
|
||||
Deze reset-link is ongeldig of verlopen.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="text-center">
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
className="text-sm text-white/60 hover:text-white"
|
||||
>
|
||||
Vraag een nieuwe reset-link aan
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex min-h-[calc(100dvh-2.75rem)] items-center justify-center overflow-y-auto px-4 py-8 sm:min-h-[calc(100dvh-3.5rem)]">
|
||||
<Card className="my-auto w-full max-w-md border-white/10 bg-white/5">
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="font-['Intro',sans-serif] text-3xl text-white">
|
||||
Nieuw wachtwoord
|
||||
</CardTitle>
|
||||
<CardDescription className="text-white/60">
|
||||
Kies een nieuw wachtwoord voor je account
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label
|
||||
htmlFor="password"
|
||||
className="mb-2 block text-sm text-white/60"
|
||||
>
|
||||
Nieuw wachtwoord
|
||||
</label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
required
|
||||
minLength={8}
|
||||
className="border-white/20 bg-white/10 text-white placeholder:text-white/40"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label
|
||||
htmlFor="confirm"
|
||||
className="mb-2 block text-sm text-white/60"
|
||||
>
|
||||
Bevestig wachtwoord
|
||||
</label>
|
||||
<Input
|
||||
id="confirm"
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
value={confirm}
|
||||
onChange={(e) => setConfirm(e.target.value)}
|
||||
required
|
||||
minLength={8}
|
||||
className="border-white/20 bg-white/10 text-white placeholder:text-white/40"
|
||||
/>
|
||||
</div>
|
||||
{mutation.isError && (
|
||||
<p className="text-red-400 text-sm">{mutation.error.message}</p>
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={mutation.isPending}
|
||||
className="w-full bg-white text-[#214e51] hover:bg-white/90"
|
||||
>
|
||||
{mutation.isPending ? "Bezig..." : "Stel wachtwoord in"}
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
72
apps/web/src/server.ts
Normal file
72
apps/web/src/server.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import type { EmailMessage } from "@kk/api/email-queue";
|
||||
import { dispatchEmailMessage } from "@kk/api/email-queue";
|
||||
import { runSendReminders } from "@kk/api/routers/index";
|
||||
import {
|
||||
createStartHandler,
|
||||
defaultStreamHandler,
|
||||
} from "@tanstack/react-start/server";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// CF Workers globals — not in DOM/ES2022 lib
|
||||
// ---------------------------------------------------------------------------
|
||||
type MessageItem<Body> = {
|
||||
body: Body;
|
||||
ack(): void;
|
||||
retry(): void;
|
||||
};
|
||||
type MessageBatch<Body> = { messages: Array<MessageItem<Body>> };
|
||||
type ExecutionContext = { waitUntil(promise: Promise<unknown>): void };
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Minimal CF Queue binding shape
|
||||
// ---------------------------------------------------------------------------
|
||||
type EmailQueue = {
|
||||
send(
|
||||
message: EmailMessage,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
sendBatch(
|
||||
messages: Array<{ body: EmailMessage }>,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
type Env = {
|
||||
EMAIL_QUEUE?: EmailQueue;
|
||||
};
|
||||
|
||||
const startHandler = createStartHandler(defaultStreamHandler);
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env) {
|
||||
// Cast required: TanStack Start's BaseContext doesn't know about emailQueue,
|
||||
// but it threads the value through to route handlers via requestContext.
|
||||
return startHandler(request, {
|
||||
context: { emailQueue: env.EMAIL_QUEUE } as Record<string, unknown>,
|
||||
});
|
||||
},
|
||||
|
||||
async queue(
|
||||
batch: MessageBatch<EmailMessage>,
|
||||
_env: Env,
|
||||
_ctx: ExecutionContext,
|
||||
) {
|
||||
for (const msg of batch.messages) {
|
||||
try {
|
||||
await dispatchEmailMessage(msg.body);
|
||||
msg.ack();
|
||||
} catch (err) {
|
||||
console.error("Queue dispatch failed:", err);
|
||||
msg.retry();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async scheduled(
|
||||
_event: { cron: string; scheduledTime: number },
|
||||
env: Env,
|
||||
ctx: ExecutionContext,
|
||||
) {
|
||||
ctx.waitUntil(runSendReminders(env.EMAIL_QUEUE));
|
||||
},
|
||||
};
|
||||
13
bun.lock
13
bun.lock
@@ -42,6 +42,7 @@
|
||||
"@tanstack/react-start": "^1.141.1",
|
||||
"@tanstack/router-plugin": "^1.141.1",
|
||||
"better-auth": "catalog:",
|
||||
"canvas-confetti": "^1.9.4",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"dotenv": "catalog:",
|
||||
@@ -66,8 +67,10 @@
|
||||
"@kk/config": "workspace:*",
|
||||
"@tanstack/react-query-devtools": "^5.91.1",
|
||||
"@tanstack/react-router-devtools": "^1.141.1",
|
||||
"@tanstack/router-core": "^1.141.1",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/react": "^16.2.0",
|
||||
"@types/canvas-confetti": "^1.9.0",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "19.2.7",
|
||||
"@types/react-dom": "19.2.3",
|
||||
@@ -93,7 +96,7 @@
|
||||
"@orpc/zod": "catalog:",
|
||||
"dotenv": "catalog:",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"nodemailer": "^8.0.1",
|
||||
"nodemailer": "^8.0.2",
|
||||
"zod": "catalog:",
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -109,10 +112,12 @@
|
||||
"@kk/env": "workspace:*",
|
||||
"better-auth": "catalog:",
|
||||
"dotenv": "catalog:",
|
||||
"nodemailer": "^8.0.2",
|
||||
"zod": "catalog:",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kk/config": "workspace:*",
|
||||
"@types/nodemailer": "^7.0.11",
|
||||
"typescript": "catalog:",
|
||||
},
|
||||
},
|
||||
@@ -909,6 +914,8 @@
|
||||
|
||||
"@types/babel__traverse": ["@types/babel__traverse@7.28.0", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="],
|
||||
|
||||
"@types/canvas-confetti": ["@types/canvas-confetti@1.9.0", "", {}, "sha512-aBGj/dULrimR1XDZLtG9JwxX1b4HPRF6CX9Yfwh3NvstZEm1ZL7RBnel4keCPSqs1ANRu1u2Aoz9R+VmtjYuTg=="],
|
||||
|
||||
"@types/draco3d": ["@types/draco3d@1.4.10", "", {}, "sha512-AX22jp8Y7wwaBgAixaSvkoG4M/+PlAcm3Qs4OW8yT9DM4xUpWKeFhLueTAyZF39pviAdcDdeJoACapiAceqNcw=="],
|
||||
|
||||
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
|
||||
@@ -1027,6 +1034,8 @@
|
||||
|
||||
"caniuse-lite": ["caniuse-lite@1.0.30001774", "", {}, "sha512-DDdwPGz99nmIEv216hKSgLD+D4ikHQHjBC/seF98N9CPqRX4M5mSxT9eTV6oyisnJcuzxtZy4n17yKKQYmYQOA=="],
|
||||
|
||||
"canvas-confetti": ["canvas-confetti@1.9.4", "", {}, "sha512-yxQbJkAVrFXWNbTUjPqjF7G+g6pDotOUHGbkZq2NELZUMDpiJ85rIEazVb8GTaAptNW2miJAXbs1BtioA251Pw=="],
|
||||
|
||||
"chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
|
||||
|
||||
"cheerio": ["cheerio@1.2.0", "", { "dependencies": { "cheerio-select": "^2.1.0", "dom-serializer": "^2.0.0", "domhandler": "^5.0.3", "domutils": "^3.2.2", "encoding-sniffer": "^0.2.1", "htmlparser2": "^10.1.0", "parse5": "^7.3.0", "parse5-htmlparser2-tree-adapter": "^7.1.0", "parse5-parser-stream": "^7.1.2", "undici": "^7.19.0", "whatwg-mimetype": "^4.0.0" } }, "sha512-WDrybc/gKFpTYQutKIK6UvfcuxijIZfMfXaYm8NMsPQxSYvf+13fXUJ4rztGGbJcBQ/GF55gvrZ0Bc0bj/mqvg=="],
|
||||
@@ -1503,7 +1512,7 @@
|
||||
|
||||
"node-releases": ["node-releases@2.0.27", "", {}, "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA=="],
|
||||
|
||||
"nodemailer": ["nodemailer@8.0.1", "", {}, "sha512-5kcldIXmaEjZcHR6F28IKGSgpmZHaF1IXLWFTG+Xh3S+Cce4MiakLtWY+PlBU69fLbRa8HlaGIrC/QolUpHkhg=="],
|
||||
"nodemailer": ["nodemailer@8.0.2", "", {}, "sha512-zbj002pZAIkWQFxyAaqoxvn+zoIwRnS40hgjqTXudKOOJkiFFgBeNqjgD3/YCR12sZnrghWYBY+yP1ZucdDRpw=="],
|
||||
|
||||
"normalize-path": ["normalize-path@3.0.0", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="],
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@orpc/zod": "catalog:",
|
||||
"dotenv": "catalog:",
|
||||
"drizzle-orm": "^0.45.1",
|
||||
"nodemailer": "^8.0.1",
|
||||
"nodemailer": "^8.0.2",
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
9
packages/api/src/constants.ts
Normal file
9
packages/api/src/constants.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Single source-of-truth for event details used across the API
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const EVENT = "Open Mic Night — vrijdag 18 april 2026";
|
||||
export const OPENS = "maandag 16 maart 2026 om 19:00";
|
||||
|
||||
// Registration opens — used for reminder scheduling windows
|
||||
export const REGISTRATION_OPENS_AT = new Date("2026-03-16T19:00:00+01:00");
|
||||
@@ -1,13 +1,33 @@
|
||||
import { auth } from "@kk/auth";
|
||||
import { env } from "@kk/env/server";
|
||||
import type { EmailMessage } from "./email-queue";
|
||||
|
||||
export async function createContext({ req }: { req: Request }) {
|
||||
// CF Workers runtime Queue type (not the alchemy resource type)
|
||||
type Queue = {
|
||||
send(
|
||||
message: EmailMessage,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
sendBatch(
|
||||
messages: Array<{ body: EmailMessage }>,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
export async function createContext({
|
||||
req,
|
||||
emailQueue,
|
||||
}: {
|
||||
req: Request;
|
||||
emailQueue?: Queue;
|
||||
}) {
|
||||
const session = await auth.api.getSession({
|
||||
headers: req.headers,
|
||||
});
|
||||
return {
|
||||
session,
|
||||
env,
|
||||
emailQueue,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
147
packages/api/src/email-queue.ts
Normal file
147
packages/api/src/email-queue.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Email queue types and dispatcher.
|
||||
*
|
||||
* All email sends are modelled as a discriminated union so the Cloudflare Queue
|
||||
* consumer can pattern-match on `msg.type` and call the right send*Email().
|
||||
*
|
||||
* The `Queue<EmailMessage>` type used in context.ts / server.ts refers to the
|
||||
* CF runtime binding type (`import type { Queue } from "@cloudflare/workers-types"`).
|
||||
*/
|
||||
|
||||
import {
|
||||
sendCancellationEmail,
|
||||
sendConfirmationEmail,
|
||||
sendPaymentConfirmationEmail,
|
||||
sendPaymentReminderEmail,
|
||||
sendReminder24hEmail,
|
||||
sendReminderEmail,
|
||||
sendSubscriptionConfirmationEmail,
|
||||
sendUpdateEmail,
|
||||
} from "./email";
|
||||
import { sendDeductionEmail } from "./lib/drinkkaart-email";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Message types — one variant per send*Email function
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export type ConfirmationMessage = {
|
||||
type: "registrationConfirmation";
|
||||
to: string;
|
||||
firstName: string;
|
||||
managementToken: string;
|
||||
wantsToPerform: boolean;
|
||||
artForm?: string | null;
|
||||
giftAmount?: number;
|
||||
drinkCardValue?: number;
|
||||
signupUrl?: string;
|
||||
};
|
||||
|
||||
export type UpdateMessage = {
|
||||
type: "updateConfirmation";
|
||||
to: string;
|
||||
firstName: string;
|
||||
managementToken: string;
|
||||
wantsToPerform: boolean;
|
||||
artForm?: string | null;
|
||||
giftAmount?: number;
|
||||
drinkCardValue?: number;
|
||||
};
|
||||
|
||||
export type CancellationMessage = {
|
||||
type: "cancellation";
|
||||
to: string;
|
||||
firstName: string;
|
||||
};
|
||||
|
||||
export type SubscriptionConfirmationMessage = {
|
||||
type: "subscriptionConfirmation";
|
||||
to: string;
|
||||
};
|
||||
|
||||
export type Reminder24hMessage = {
|
||||
type: "reminder24h";
|
||||
to: string;
|
||||
firstName?: string | null;
|
||||
};
|
||||
|
||||
export type Reminder1hMessage = {
|
||||
type: "reminder1h";
|
||||
to: string;
|
||||
firstName?: string | null;
|
||||
};
|
||||
|
||||
export type PaymentReminderMessage = {
|
||||
type: "paymentReminder";
|
||||
to: string;
|
||||
firstName: string;
|
||||
managementToken: string;
|
||||
drinkCardValue?: number;
|
||||
giftAmount?: number;
|
||||
};
|
||||
|
||||
export type PaymentConfirmationMessage = {
|
||||
type: "paymentConfirmation";
|
||||
to: string;
|
||||
firstName: string;
|
||||
managementToken: string;
|
||||
drinkCardValue?: number;
|
||||
giftAmount?: number;
|
||||
};
|
||||
|
||||
export type DeductionMessage = {
|
||||
type: "deduction";
|
||||
to: string;
|
||||
firstName: string;
|
||||
amountCents: number;
|
||||
newBalanceCents: number;
|
||||
};
|
||||
|
||||
export type EmailMessage =
|
||||
| ConfirmationMessage
|
||||
| UpdateMessage
|
||||
| CancellationMessage
|
||||
| SubscriptionConfirmationMessage
|
||||
| Reminder24hMessage
|
||||
| Reminder1hMessage
|
||||
| PaymentReminderMessage
|
||||
| PaymentConfirmationMessage
|
||||
| DeductionMessage;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Consumer-side dispatcher — called once per queue message
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function dispatchEmailMessage(msg: EmailMessage): Promise<void> {
|
||||
switch (msg.type) {
|
||||
case "registrationConfirmation":
|
||||
await sendConfirmationEmail(msg);
|
||||
break;
|
||||
case "updateConfirmation":
|
||||
await sendUpdateEmail(msg);
|
||||
break;
|
||||
case "cancellation":
|
||||
await sendCancellationEmail(msg);
|
||||
break;
|
||||
case "subscriptionConfirmation":
|
||||
await sendSubscriptionConfirmationEmail({ to: msg.to });
|
||||
break;
|
||||
case "reminder24h":
|
||||
await sendReminder24hEmail(msg);
|
||||
break;
|
||||
case "reminder1h":
|
||||
await sendReminderEmail(msg);
|
||||
break;
|
||||
case "paymentReminder":
|
||||
await sendPaymentReminderEmail(msg);
|
||||
break;
|
||||
case "paymentConfirmation":
|
||||
await sendPaymentConfirmationEmail(msg);
|
||||
break;
|
||||
case "deduction":
|
||||
await sendDeductionEmail(msg);
|
||||
break;
|
||||
default:
|
||||
// Exhaustiveness check — TypeScript will catch unhandled variants at compile time
|
||||
msg satisfies never;
|
||||
}
|
||||
}
|
||||
@@ -1,276 +1,186 @@
|
||||
import { env } from "@kk/env/server";
|
||||
import nodemailer from "nodemailer";
|
||||
import { EVENT, OPENS } from "./constants";
|
||||
|
||||
// Singleton transport — created once per module, reused across all email sends.
|
||||
// Re-creating it on every call causes EventEmitter listener accumulation in
|
||||
// long-lived Cloudflare Worker processes, triggering memory leak warnings.
|
||||
let _transport: nodemailer.Transporter | null | undefined;
|
||||
// ---------------------------------------------------------------------------
|
||||
// Transport — singleton so a warm CF isolate reuses the open TCP connection
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
let _transport: nodemailer.Transporter | undefined;
|
||||
|
||||
function getTransport(): nodemailer.Transporter | null {
|
||||
if (_transport !== undefined) return _transport;
|
||||
if (_transport) return _transport;
|
||||
if (!env.SMTP_HOST || !env.SMTP_USER || !env.SMTP_PASS) {
|
||||
_transport = null;
|
||||
// Not cached — re-evaluated on every call so a cold isolate that
|
||||
// receives vars after module init can still pick them up.
|
||||
return null;
|
||||
}
|
||||
_transport = nodemailer.createTransport({
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
secure: env.SMTP_PORT === 465,
|
||||
auth: {
|
||||
user: env.SMTP_USER,
|
||||
pass: env.SMTP_PASS,
|
||||
},
|
||||
auth: { user: env.SMTP_USER, pass: env.SMTP_PASS },
|
||||
});
|
||||
return _transport;
|
||||
}
|
||||
|
||||
const from = env.SMTP_FROM ?? "Kunstenkamp <info@kunstenkamp.be>";
|
||||
const baseUrl = env.BETTER_AUTH_URL ?? "https://kunstenkamp.be";
|
||||
// ---------------------------------------------------------------------------
|
||||
// Logging — console.log(JSON) is the only thing visible in CF dashboard
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function registrationConfirmationHtml(params: {
|
||||
firstName: string;
|
||||
manageUrl: string;
|
||||
wantsToPerform: boolean;
|
||||
artForm?: string | null;
|
||||
giftAmount?: number;
|
||||
drinkCardValue?: number;
|
||||
}) {
|
||||
const role = params.wantsToPerform
|
||||
? `Optreden${params.artForm ? ` — ${params.artForm}` : ""}`
|
||||
export function emailLog(
|
||||
level: "info" | "warn" | "error",
|
||||
event: string,
|
||||
extra?: Record<string, unknown>,
|
||||
): void {
|
||||
console.log(JSON.stringify({ level, event, ...extra }));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// HTML helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Primary or secondary CTA button */
|
||||
function btn(
|
||||
href: string,
|
||||
label: string,
|
||||
variant: "primary" | "secondary" = "primary",
|
||||
): string {
|
||||
const bg = variant === "primary" ? "#fff" : "rgba(255,255,255,0.15)";
|
||||
const color = variant === "primary" ? "#214e51" : "#fff";
|
||||
return `<table cellpadding="0" cellspacing="0" style="margin:0 0 16px;">
|
||||
<tr><td style="border-radius:2px;background:${bg};">
|
||||
<a href="${href}" style="display:inline-block;padding:14px 32px;font-size:16px;font-weight:600;color:${color};text-decoration:none;">${label}</a>
|
||||
</td></tr>
|
||||
</table>`;
|
||||
}
|
||||
|
||||
/** Info card — single label + value */
|
||||
function card(label: string, value: string): string {
|
||||
return `<table width="100%" cellpadding="0" cellspacing="0" style="background:rgba(255,255,255,0.08);border-radius:4px;margin:24px 0;">
|
||||
<tr><td style="padding:20px 24px;">
|
||||
<p style="margin:0 0 8px;font-size:12px;color:rgba(255,255,255,0.5);text-transform:uppercase;letter-spacing:0.06em;">${label}</p>
|
||||
<p style="margin:0;font-size:18px;color:#fff;font-weight:600;">${value}</p>
|
||||
</td></tr>
|
||||
</table>`;
|
||||
}
|
||||
|
||||
/** Payment breakdown card — renders only when totalCents > 0 */
|
||||
function paymentCard(drinkCardCents: number, giftCents: number): string {
|
||||
const total = drinkCardCents + giftCents;
|
||||
if (total === 0) return "";
|
||||
return `<table width="100%" cellpadding="0" cellspacing="0" style="background:rgba(255,255,255,0.08);border-radius:4px;margin:16px 0;">
|
||||
<tr><td style="padding:20px 24px;">
|
||||
<p style="margin:0 0 12px;font-size:12px;color:rgba(255,255,255,0.5);text-transform:uppercase;letter-spacing:0.06em;">Betaling</p>
|
||||
${drinkCardCents > 0 ? `<p style="margin:0 0 8px;font-size:16px;color:rgba(255,255,255,0.85);">Drinkkaart: <strong style="color:#fff;">${euro(drinkCardCents)}</strong></p>` : ""}
|
||||
${giftCents > 0 ? `<p style="margin:0 0 8px;font-size:16px;color:rgba(255,255,255,0.85);">Vrijwillige gift: <strong style="color:#fff;">${euro(giftCents)}</strong></p>` : ""}
|
||||
<p style="margin:16px 0 0;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1);font-size:18px;color:#fff;font-weight:600;">Totaal: ${euro(total)}</p>
|
||||
</td></tr>
|
||||
</table>`;
|
||||
}
|
||||
|
||||
/** Shared text paragraph */
|
||||
function p(text: string): string {
|
||||
return `<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">${text}</p>`;
|
||||
}
|
||||
|
||||
/** Muted footnote */
|
||||
function note(html: string): string {
|
||||
return `<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.4);">${html}</p>`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Email layout shell
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function emailLayout(heading: string, body: string): string {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<title>${heading}</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#f4f4f5;font-family:sans-serif;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:40px 0;">
|
||||
<tr><td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background:#214e51;border-radius:4px;overflow:hidden;">
|
||||
<tr><td style="padding:40px 48px 32px;">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.5);letter-spacing:0.08em;text-transform:uppercase;">Kunstenkamp</p>
|
||||
<h1 style="margin:12px 0 0;font-size:28px;color:#fff;font-weight:700;">${heading}</h1>
|
||||
</td></tr>
|
||||
<tr><td style="padding:0 48px 32px;">${body}</td></tr>
|
||||
<tr><td style="padding:24px 48px;border-top:1px solid rgba(255,255,255,0.1);">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.4);line-height:1.6;">
|
||||
Vragen? Mail ons op <a href="mailto:info@kunstenkamp.be" style="color:rgba(255,255,255,0.6);">info@kunstenkamp.be</a><br/>
|
||||
Kunstenkamp vzw — Een initiatief voor en door kunstenaars.
|
||||
</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Shared send helper — logs attempt/sent/error, skips when SMTP not configured
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function send(
|
||||
type: string,
|
||||
to: string,
|
||||
subject: string,
|
||||
html: string,
|
||||
): Promise<void> {
|
||||
emailLog("info", "email.attempt", { type, to });
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
emailLog("warn", "email.skipped", {
|
||||
type,
|
||||
to,
|
||||
reason: "smtp_not_configured",
|
||||
// Which vars are missing — helps diagnose CF env issues
|
||||
hasHost: !!env.SMTP_HOST,
|
||||
hasUser: !!env.SMTP_USER,
|
||||
hasPass: !!env.SMTP_PASS,
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await transport.sendMail({ from: env.SMTP_FROM, to, subject, html });
|
||||
emailLog("info", "email.sent", { type, to });
|
||||
} catch (err) {
|
||||
emailLog("error", "email.error", { type, to, error: String(err) });
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Euro formatter
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function euro(cents: number): string {
|
||||
return `€${(cents / 100).toFixed(cents % 100 === 0 ? 0 : 2).replace(".", ",")}`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers for registration emails
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function roleLabel(wantsToPerform: boolean, artForm?: string | null): string {
|
||||
return wantsToPerform
|
||||
? `Optreden${artForm ? ` — ${artForm}` : ""}`
|
||||
: "Toeschouwer";
|
||||
|
||||
const giftCents = params.giftAmount ?? 0;
|
||||
// drinkCardValue is stored in euros (e.g., 5), giftAmount in cents (e.g., 5000)
|
||||
const drinkCardCents = (params.drinkCardValue ?? 0) * 100;
|
||||
const hasPayment = drinkCardCents > 0 || giftCents > 0;
|
||||
|
||||
const formatEuro = (cents: number) =>
|
||||
`€${(cents / 100).toFixed(cents % 100 === 0 ? 0 : 2).replace(".", ",")}`;
|
||||
|
||||
const paymentSummary = hasPayment
|
||||
? `<table width="100%" cellpadding="0" cellspacing="0" style="background:rgba(255,255,255,0.08);border-radius:4px;margin:16px 0;">
|
||||
<tr>
|
||||
<td style="padding:20px 24px;">
|
||||
<p style="margin:0 0 12px;font-size:12px;color:rgba(255,255,255,0.5);text-transform:uppercase;letter-spacing:0.06em;">Betaling</p>
|
||||
${drinkCardCents > 0 ? `<p style="margin:0 0 8px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.5;">Drinkkaart: <span style="color:#ffffff;font-weight:500;">${formatEuro(drinkCardCents)}</span></p>` : ""}
|
||||
${giftCents > 0 ? `<p style="margin:0 0 8px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.5;">Vrijwillige gift: <span style="color:#ffffff;font-weight:500;">${formatEuro(giftCents)}</span></p>` : ""}
|
||||
<p style="margin:16px 0 0;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1);font-size:18px;color:#ffffff;font-weight:600;">Totaal: ${formatEuro(drinkCardCents + giftCents)}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>`
|
||||
: "";
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Bevestiging inschrijving</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#f4f4f5;font-family:sans-serif;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:40px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background:#214e51;border-radius:4px;overflow:hidden;">
|
||||
<!-- Header -->
|
||||
<tr>
|
||||
<td style="padding:40px 48px 32px;">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.5);letter-spacing:0.08em;text-transform:uppercase;">Kunstenkamp</p>
|
||||
<h1 style="margin:12px 0 0;font-size:28px;color:#ffffff;font-weight:700;">Je inschrijving is bevestigd!</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Body -->
|
||||
<tr>
|
||||
<td style="padding:0 48px 32px;">
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Hoi ${params.firstName},
|
||||
</p>
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
We hebben je inschrijving voor <strong style="color:#ffffff;">Open Mic Night — vrijdag 18 april 2026</strong> in goede orde ontvangen.
|
||||
</p>
|
||||
<!-- Registration summary -->
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:rgba(255,255,255,0.08);border-radius:4px;margin:24px 0;">
|
||||
<tr>
|
||||
<td style="padding:20px 24px;">
|
||||
<p style="margin:0 0 8px;font-size:12px;color:rgba(255,255,255,0.5);text-transform:uppercase;letter-spacing:0.06em;">Jouw rol</p>
|
||||
<p style="margin:0;font-size:18px;color:#ffffff;font-weight:600;">${role}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
${paymentSummary}
|
||||
<p style="margin:0 0 24px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Wil je je gegevens later nog aanpassen of je inschrijving annuleren? Gebruik dan de knop hieronder. De link is uniek voor jou — deel hem niet.
|
||||
</p>
|
||||
<!-- CTA button -->
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="border-radius:2px;background:#ffffff;">
|
||||
<a href="${params.manageUrl}" style="display:inline-block;padding:14px 32px;font-size:16px;font-weight:600;color:#214e51;text-decoration:none;">
|
||||
Beheer mijn inschrijving
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="margin:16px 0 0;font-size:13px;color:rgba(255,255,255,0.4);">
|
||||
Of kopieer deze link: <span style="color:rgba(255,255,255,0.6);">${params.manageUrl}</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- Footer -->
|
||||
<tr>
|
||||
<td style="padding:24px 48px;border-top:1px solid rgba(255,255,255,0.1);">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.4);line-height:1.6;">
|
||||
Vragen? Mail ons op <a href="mailto:info@kunstenkamp.be" style="color:rgba(255,255,255,0.6);">info@kunstenkamp.be</a><br/>
|
||||
Kunstenkamp vzw — Een initiatief voor en door kunstenaars.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
function updateConfirmationHtml(params: {
|
||||
firstName: string;
|
||||
manageUrl: string;
|
||||
wantsToPerform: boolean;
|
||||
artForm?: string | null;
|
||||
giftAmount?: number;
|
||||
drinkCardValue?: number;
|
||||
}) {
|
||||
const role = params.wantsToPerform
|
||||
? `Optreden${params.artForm ? ` — ${params.artForm}` : ""}`
|
||||
: "Toeschouwer";
|
||||
|
||||
const giftCents = params.giftAmount ?? 0;
|
||||
// drinkCardValue is stored in euros (e.g., 5), giftAmount in cents (e.g., 5000)
|
||||
const drinkCardCents = (params.drinkCardValue ?? 0) * 100;
|
||||
const hasPayment = drinkCardCents > 0 || giftCents > 0;
|
||||
|
||||
const formatEuro = (cents: number) =>
|
||||
`€${(cents / 100).toFixed(cents % 100 === 0 ? 0 : 2).replace(".", ",")}`;
|
||||
|
||||
const paymentSummary = hasPayment
|
||||
? `<table width="100%" cellpadding="0" cellspacing="0" style="background:rgba(255,255,255,0.08);border-radius:4px;margin:16px 0;">
|
||||
<tr>
|
||||
<td style="padding:20px 24px;">
|
||||
<p style="margin:0 0 12px;font-size:12px;color:rgba(255,255,255,0.5);text-transform:uppercase;letter-spacing:0.06em;">Betaling</p>
|
||||
${drinkCardCents > 0 ? `<p style="margin:0 0 8px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.5;">Drinkkaart: <span style="color:#ffffff;font-weight:500;">${formatEuro(drinkCardCents)}</span></p>` : ""}
|
||||
${giftCents > 0 ? `<p style="margin:0 0 8px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.5;">Vrijwillige gift: <span style="color:#ffffff;font-weight:500;">${formatEuro(giftCents)}</span></p>` : ""}
|
||||
<p style="margin:16px 0 0;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1);font-size:18px;color:#ffffff;font-weight:600;">Totaal: ${formatEuro(drinkCardCents + giftCents)}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>`
|
||||
: "";
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Inschrijving bijgewerkt</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#f4f4f5;font-family:sans-serif;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:40px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background:#214e51;border-radius:4px;overflow:hidden;">
|
||||
<tr>
|
||||
<td style="padding:40px 48px 32px;">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.5);letter-spacing:0.08em;text-transform:uppercase;">Kunstenkamp</p>
|
||||
<h1 style="margin:12px 0 0;font-size:28px;color:#ffffff;font-weight:700;">Inschrijving bijgewerkt</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 48px 32px;">
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Hoi ${params.firstName},
|
||||
</p>
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Je inschrijving voor <strong style="color:#ffffff;">Open Mic Night — vrijdag 18 april 2026</strong> is succesvol bijgewerkt.
|
||||
</p>
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:rgba(255,255,255,0.08);border-radius:4px;margin:24px 0;">
|
||||
<tr>
|
||||
<td style="padding:20px 24px;">
|
||||
<p style="margin:0 0 8px;font-size:12px;color:rgba(255,255,255,0.5);text-transform:uppercase;letter-spacing:0.06em;">Jouw rol</p>
|
||||
<p style="margin:0;font-size:18px;color:#ffffff;font-weight:600;">${role}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
${paymentSummary}
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="border-radius:2px;background:#ffffff;">
|
||||
<a href="${params.manageUrl}" style="display:inline-block;padding:14px 32px;font-size:16px;font-weight:600;color:#214e51;text-decoration:none;">
|
||||
Bekijk mijn inschrijving
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:24px 48px;border-top:1px solid rgba(255,255,255,0.1);">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.4);">
|
||||
Vragen? Mail ons op <a href="mailto:info@kunstenkamp.be" style="color:rgba(255,255,255,0.6);">info@kunstenkamp.be</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
function manageUrl(token: string): string {
|
||||
return `${env.BETTER_AUTH_URL}/manage/${token}`;
|
||||
}
|
||||
|
||||
function cancellationHtml(params: { firstName: string }) {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Inschrijving geannuleerd</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#f4f4f5;font-family:sans-serif;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:40px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background:#214e51;border-radius:4px;overflow:hidden;">
|
||||
<tr>
|
||||
<td style="padding:40px 48px 32px;">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.5);letter-spacing:0.08em;text-transform:uppercase;">Kunstenkamp</p>
|
||||
<h1 style="margin:12px 0 0;font-size:28px;color:#ffffff;font-weight:700;">Inschrijving geannuleerd</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 48px 40px;">
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Hoi ${params.firstName},
|
||||
</p>
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Je inschrijving voor <strong style="color:#ffffff;">Open Mic Night — vrijdag 18 april 2026</strong> is geannuleerd.
|
||||
</p>
|
||||
<p style="margin:0;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Van gedachten veranderd? Je kunt je altijd opnieuw inschrijven via <a href="${baseUrl}/#registration" style="color:#ffffff;">kunstenkamp.be</a>.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:24px 48px;border-top:1px solid rgba(255,255,255,0.1);">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.4);">
|
||||
Vragen? Mail ons op <a href="mailto:info@kunstenkamp.be" style="color:rgba(255,255,255,0.6);">info@kunstenkamp.be</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Emails
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function sendConfirmationEmail(params: {
|
||||
to: string;
|
||||
@@ -280,26 +190,40 @@ export async function sendConfirmationEmail(params: {
|
||||
artForm?: string | null;
|
||||
giftAmount?: number;
|
||||
drinkCardValue?: number;
|
||||
signupUrl?: string;
|
||||
}) {
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping confirmation email");
|
||||
return;
|
||||
}
|
||||
const manageUrl = `${baseUrl}/manage/${params.managementToken}`;
|
||||
await transport.sendMail({
|
||||
from,
|
||||
to: params.to,
|
||||
subject: "Bevestiging inschrijving — Open Mic Night",
|
||||
html: registrationConfirmationHtml({
|
||||
firstName: params.firstName,
|
||||
manageUrl,
|
||||
wantsToPerform: params.wantsToPerform,
|
||||
artForm: params.artForm,
|
||||
giftAmount: params.giftAmount,
|
||||
drinkCardValue: params.drinkCardValue,
|
||||
}),
|
||||
});
|
||||
const manage = manageUrl(params.managementToken);
|
||||
const signup =
|
||||
params.signupUrl ??
|
||||
`${env.BETTER_AUTH_URL}/login?signup=1&email=${encodeURIComponent(params.to)}&next=/account`;
|
||||
const drinkCardCents = (params.drinkCardValue ?? 0) * 100;
|
||||
const giftCents = params.giftAmount ?? 0;
|
||||
|
||||
await send(
|
||||
"registrationConfirmation",
|
||||
params.to,
|
||||
"Bevestiging inschrijving — Open Mic Night",
|
||||
emailLayout(
|
||||
"Je inschrijving is bevestigd!",
|
||||
p(`Hoi ${params.firstName},`) +
|
||||
p(
|
||||
`We hebben je inschrijving voor <strong style="color:#fff;">${EVENT}</strong> in goede orde ontvangen.`,
|
||||
) +
|
||||
card("Jouw rol", roleLabel(params.wantsToPerform, params.artForm)) +
|
||||
paymentCard(drinkCardCents, giftCents) +
|
||||
p(
|
||||
"Maak een account aan om je inschrijving te beheren en je Drinkkaart te activeren.",
|
||||
) +
|
||||
btn(signup, "Account aanmaken") +
|
||||
p(
|
||||
"Wil je je gegevens aanpassen of je inschrijving annuleren? De link hieronder is uniek voor jou — deel hem niet.",
|
||||
) +
|
||||
btn(manage, "Beheer mijn inschrijving", "secondary") +
|
||||
note(
|
||||
`Of kopieer: <span style="color:rgba(255,255,255,0.6);">${manage}</span>`,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendUpdateEmail(params: {
|
||||
@@ -311,40 +235,180 @@ export async function sendUpdateEmail(params: {
|
||||
giftAmount?: number;
|
||||
drinkCardValue?: number;
|
||||
}) {
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping update email");
|
||||
return;
|
||||
}
|
||||
const manageUrl = `${baseUrl}/manage/${params.managementToken}`;
|
||||
await transport.sendMail({
|
||||
from,
|
||||
to: params.to,
|
||||
subject: "Inschrijving bijgewerkt — Open Mic Night",
|
||||
html: updateConfirmationHtml({
|
||||
firstName: params.firstName,
|
||||
manageUrl,
|
||||
wantsToPerform: params.wantsToPerform,
|
||||
artForm: params.artForm,
|
||||
giftAmount: params.giftAmount,
|
||||
drinkCardValue: params.drinkCardValue,
|
||||
}),
|
||||
});
|
||||
const manage = manageUrl(params.managementToken);
|
||||
const drinkCardCents = (params.drinkCardValue ?? 0) * 100;
|
||||
const giftCents = params.giftAmount ?? 0;
|
||||
|
||||
await send(
|
||||
"updateConfirmation",
|
||||
params.to,
|
||||
"Inschrijving bijgewerkt — Open Mic Night",
|
||||
emailLayout(
|
||||
"Inschrijving bijgewerkt",
|
||||
p(`Hoi ${params.firstName},`) +
|
||||
p(
|
||||
`Je inschrijving voor <strong style="color:#fff;">${EVENT}</strong> is succesvol bijgewerkt.`,
|
||||
) +
|
||||
card("Jouw rol", roleLabel(params.wantsToPerform, params.artForm)) +
|
||||
paymentCard(drinkCardCents, giftCents) +
|
||||
btn(manage, "Bekijk mijn inschrijving"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendCancellationEmail(params: {
|
||||
to: string;
|
||||
firstName: string;
|
||||
}) {
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping cancellation email");
|
||||
return;
|
||||
}
|
||||
await transport.sendMail({
|
||||
from,
|
||||
to: params.to,
|
||||
subject: "Inschrijving geannuleerd — Open Mic Night",
|
||||
html: cancellationHtml({ firstName: params.firstName }),
|
||||
});
|
||||
await send(
|
||||
"cancellation",
|
||||
params.to,
|
||||
"Inschrijving geannuleerd — Open Mic Night",
|
||||
emailLayout(
|
||||
"Inschrijving geannuleerd",
|
||||
p(`Hoi ${params.firstName},`) +
|
||||
p(
|
||||
`Je inschrijving voor <strong style="color:#fff;">${EVENT}</strong> is geannuleerd.`,
|
||||
) +
|
||||
p(
|
||||
`Van gedachten veranderd? Je kunt je altijd opnieuw inschrijven via <a href="${env.BETTER_AUTH_URL}/#registration" style="color:#fff;">kunstenkamp.be</a>.`,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendSubscriptionConfirmationEmail(params: {
|
||||
to: string;
|
||||
}) {
|
||||
await send(
|
||||
"subscriptionConfirmation",
|
||||
params.to,
|
||||
"Herinnering ingepland — Open Mic Night",
|
||||
emailLayout(
|
||||
"Je herinnering is ingepland!",
|
||||
p(
|
||||
`We sturen een herinnering naar <strong style="color:#fff;">${params.to}</strong> wanneer de inschrijvingen openen.`,
|
||||
) +
|
||||
card("Inschrijvingen openen", OPENS) +
|
||||
p(
|
||||
"Je ontvangt twee herinneringen: één 24 uur van tevoren en één 1 uur voor de opening.",
|
||||
) +
|
||||
p("Wees er snel bij — de plaatsen zijn beperkt!") +
|
||||
btn(`${env.BETTER_AUTH_URL}/#registration`, "Bekijk de pagina"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendReminder24hEmail(params: {
|
||||
to: string;
|
||||
firstName?: string | null;
|
||||
}) {
|
||||
const greeting = params.firstName ? `Hoi ${params.firstName},` : "Hoi!";
|
||||
|
||||
await send(
|
||||
"reminder24h",
|
||||
params.to,
|
||||
"Nog 24 uur — inschrijvingen openen morgen!",
|
||||
emailLayout(
|
||||
"Nog 24 uur!",
|
||||
p(greeting) +
|
||||
p(
|
||||
`Morgen openen de inschrijvingen voor <strong style="color:#fff;">${EVENT}</strong>. Zet je wekker!`,
|
||||
) +
|
||||
card("Inschrijvingen openen", OPENS) +
|
||||
p("Wees er snel bij — de plaatsen zijn beperkt!") +
|
||||
btn(`${env.BETTER_AUTH_URL}/#registration`, "Bekijk de pagina") +
|
||||
note(
|
||||
"Je ontvangt dit bericht omdat je een herinnering hebt aangevraagd op kunstenkamp.be.",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendReminderEmail(params: {
|
||||
to: string;
|
||||
firstName?: string | null;
|
||||
}) {
|
||||
const greeting = params.firstName ? `Hoi ${params.firstName},` : "Hoi!";
|
||||
|
||||
await send(
|
||||
"reminder1h",
|
||||
params.to,
|
||||
"Nog 1 uur — inschrijvingen openen straks!",
|
||||
emailLayout(
|
||||
"Nog 1 uur!",
|
||||
p(greeting) +
|
||||
p(
|
||||
`Over ongeveer <strong style="color:#fff;">1 uur</strong> openen de inschrijvingen voor <strong style="color:#fff;">${EVENT}</strong>.`,
|
||||
) +
|
||||
card("Inschrijvingen openen", OPENS) +
|
||||
p("Wees er snel bij — de plaatsen zijn beperkt!") +
|
||||
btn(`${env.BETTER_AUTH_URL}/#registration`, "Schrijf je in") +
|
||||
note(
|
||||
"Je ontvangt dit bericht omdat je een herinnering hebt aangevraagd op kunstenkamp.be.",
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendPaymentReminderEmail(params: {
|
||||
to: string;
|
||||
firstName: string;
|
||||
managementToken: string;
|
||||
drinkCardValue?: number;
|
||||
giftAmount?: number;
|
||||
}) {
|
||||
const manage = manageUrl(params.managementToken);
|
||||
const drinkCardCents = (params.drinkCardValue ?? 0) * 100;
|
||||
const giftCents = params.giftAmount ?? 0;
|
||||
const total = drinkCardCents + giftCents;
|
||||
const amountNote =
|
||||
total > 0
|
||||
? `Je betaling van <strong style="color:#fff;">${euro(total)}</strong> staat nog open.`
|
||||
: "Je betaling staat nog open.";
|
||||
|
||||
await send(
|
||||
"paymentReminder",
|
||||
params.to,
|
||||
"Herinnering: betaling open — Open Mic Night",
|
||||
emailLayout(
|
||||
"Betaling nog open",
|
||||
p(`Hoi ${params.firstName},`) +
|
||||
p(
|
||||
`Je hebt je ingeschreven voor <strong style="color:#fff;">${EVENT}</strong>, maar we hebben nog geen betaling ontvangen.`,
|
||||
) +
|
||||
p(`${amountNote} Log in op je account om te betalen.`) +
|
||||
btn(`${env.BETTER_AUTH_URL}/account`, "Betaal nu") +
|
||||
note(
|
||||
`Je inschrijving beheren? <a href="${manage}" style="color:rgba(255,255,255,0.6);">Klik hier</a>`,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export async function sendPaymentConfirmationEmail(params: {
|
||||
to: string;
|
||||
firstName: string;
|
||||
managementToken: string;
|
||||
drinkCardValue?: number;
|
||||
giftAmount?: number;
|
||||
}) {
|
||||
const manage = manageUrl(params.managementToken);
|
||||
const drinkCardCents = (params.drinkCardValue ?? 0) * 100;
|
||||
const giftCents = params.giftAmount ?? 0;
|
||||
|
||||
await send(
|
||||
"paymentConfirmation",
|
||||
params.to,
|
||||
"Betaling ontvangen — Open Mic Night",
|
||||
emailLayout(
|
||||
"Betaling ontvangen!",
|
||||
p(`Hoi ${params.firstName},`) +
|
||||
p(
|
||||
`We hebben je betaling voor <strong style="color:#fff;">${EVENT}</strong> in goede orde ontvangen. Tot dan!`,
|
||||
) +
|
||||
paymentCard(drinkCardCents, giftCents) +
|
||||
btn(manage, "Beheer mijn inschrijving", "secondary"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { env } from "@kk/env/server";
|
||||
import nodemailer from "nodemailer";
|
||||
import { emailLog } from "../email";
|
||||
|
||||
// Re-use the same SMTP transport strategy as email.ts.
|
||||
let _transport: nodemailer.Transporter | null | undefined;
|
||||
// Re-use the same SMTP transport strategy as email.ts:
|
||||
// only cache a successfully-created transporter; never cache null so that a
|
||||
// cold isolate that receives env vars after module init can still pick them up.
|
||||
let _transport: nodemailer.Transporter | undefined;
|
||||
|
||||
function getTransport(): nodemailer.Transporter | null {
|
||||
if (_transport !== undefined) return _transport;
|
||||
if (_transport) return _transport;
|
||||
if (!env.SMTP_HOST || !env.SMTP_USER || !env.SMTP_PASS) {
|
||||
_transport = null;
|
||||
return null;
|
||||
}
|
||||
_transport = nodemailer.createTransport({
|
||||
@@ -22,9 +24,6 @@ function getTransport(): nodemailer.Transporter | null {
|
||||
return _transport;
|
||||
}
|
||||
|
||||
const from = env.SMTP_FROM ?? "Kunstenkamp <info@kunstenkamp.be>";
|
||||
const baseUrl = env.BETTER_AUTH_URL ?? "https://kunstenkamp.be";
|
||||
|
||||
function formatEuro(cents: number): string {
|
||||
return new Intl.NumberFormat("nl-BE", {
|
||||
style: "currency",
|
||||
@@ -116,7 +115,7 @@ function deductionHtml(params: {
|
||||
|
||||
/**
|
||||
* Send a deduction notification email to the cardholder.
|
||||
* Fire-and-forget: errors are logged but not re-thrown.
|
||||
* Throws on SMTP error so the queue consumer can retry.
|
||||
*/
|
||||
export async function sendDeductionEmail(params: {
|
||||
to: string;
|
||||
@@ -124,9 +123,18 @@ export async function sendDeductionEmail(params: {
|
||||
amountCents: number;
|
||||
newBalanceCents: number;
|
||||
}): Promise<void> {
|
||||
emailLog("info", "email.attempt", { type: "deduction", to: params.to });
|
||||
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping deduction email");
|
||||
emailLog("warn", "email.skipped", {
|
||||
type: "deduction",
|
||||
to: params.to,
|
||||
reason: "smtp_not_configured",
|
||||
hasHost: !!env.SMTP_HOST,
|
||||
hasUser: !!env.SMTP_USER,
|
||||
hasPass: !!env.SMTP_PASS,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,16 +152,26 @@ export async function sendDeductionEmail(params: {
|
||||
currency: "EUR",
|
||||
}).format(params.amountCents / 100);
|
||||
|
||||
await transport.sendMail({
|
||||
from,
|
||||
to: params.to,
|
||||
subject: `Drinkkaart — ${amountFormatted} afgeschreven`,
|
||||
html: deductionHtml({
|
||||
firstName: params.firstName,
|
||||
amountCents: params.amountCents,
|
||||
newBalanceCents: params.newBalanceCents,
|
||||
dateTime,
|
||||
drinkkaartUrl: `${baseUrl}/drinkkaart`,
|
||||
}),
|
||||
});
|
||||
try {
|
||||
await transport.sendMail({
|
||||
from: env.SMTP_FROM,
|
||||
to: params.to,
|
||||
subject: `Drinkkaart — ${amountFormatted} afgeschreven`,
|
||||
html: deductionHtml({
|
||||
firstName: params.firstName,
|
||||
amountCents: params.amountCents,
|
||||
newBalanceCents: params.newBalanceCents,
|
||||
dateTime,
|
||||
drinkkaartUrl: `${env.BETTER_AUTH_URL}/drinkkaart`,
|
||||
}),
|
||||
});
|
||||
emailLog("info", "email.sent", { type: "deduction", to: params.to });
|
||||
} catch (err) {
|
||||
emailLog("error", "email.error", {
|
||||
type: "deduction",
|
||||
to: params.to,
|
||||
error: String(err),
|
||||
});
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { user } from "@kk/db/schema/auth";
|
||||
import { ORPCError } from "@orpc/server";
|
||||
import { and, desc, eq, gte, lte, sql } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import type { EmailMessage } from "../email-queue";
|
||||
import { adminProcedure, protectedProcedure } from "../index";
|
||||
import { sendDeductionEmail } from "../lib/drinkkaart-email";
|
||||
import {
|
||||
@@ -339,7 +340,7 @@ export const drinkkaartRouter = {
|
||||
createdAt: now,
|
||||
});
|
||||
|
||||
// Fire-and-forget deduction email
|
||||
// Fire-and-forget deduction email (via queue when available)
|
||||
const cardUser = await db
|
||||
.select({ email: user.email, name: user.name })
|
||||
.from(user)
|
||||
@@ -348,14 +349,21 @@ export const drinkkaartRouter = {
|
||||
.then((r) => r[0]);
|
||||
|
||||
if (cardUser) {
|
||||
sendDeductionEmail({
|
||||
const deductionMsg: EmailMessage = {
|
||||
type: "deduction",
|
||||
to: cardUser.email,
|
||||
firstName: cardUser.name.split(" ")[0] ?? cardUser.name,
|
||||
amountCents: input.amountCents,
|
||||
newBalanceCents: balanceAfter,
|
||||
}).catch((err) =>
|
||||
console.error("Failed to send deduction email:", err),
|
||||
);
|
||||
};
|
||||
|
||||
if (context.emailQueue) {
|
||||
await context.emailQueue.send(deductionMsg);
|
||||
} else {
|
||||
await sendDeductionEmail(deductionMsg).catch((err) =>
|
||||
console.error("Failed to send deduction email:", err),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,21 +1,63 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { db } from "@kk/db";
|
||||
import { adminRequest, registration } from "@kk/db/schema";
|
||||
import { adminRequest, registration, reminder } from "@kk/db/schema";
|
||||
import { user } from "@kk/db/schema/auth";
|
||||
import { drinkkaart, drinkkaartTopup } from "@kk/db/schema/drinkkaart";
|
||||
import { env } from "@kk/env/server";
|
||||
import type { RouterClient } from "@orpc/server";
|
||||
import { and, count, desc, eq, gte, isNull, like, lte, sum } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
and,
|
||||
count,
|
||||
desc,
|
||||
eq,
|
||||
gte,
|
||||
isNull,
|
||||
like,
|
||||
lte,
|
||||
or,
|
||||
sum,
|
||||
} from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
import { REGISTRATION_OPENS_AT } from "../constants";
|
||||
import {
|
||||
emailLog,
|
||||
sendCancellationEmail,
|
||||
sendConfirmationEmail,
|
||||
sendPaymentReminderEmail,
|
||||
sendReminder24hEmail,
|
||||
sendReminderEmail,
|
||||
sendSubscriptionConfirmationEmail,
|
||||
sendUpdateEmail,
|
||||
} from "../email";
|
||||
import type { EmailMessage } from "../email-queue";
|
||||
|
||||
// Minimal CF Queue binding shape (mirrors context.ts)
|
||||
type EmailQueue = {
|
||||
send(
|
||||
message: EmailMessage,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
sendBatch(
|
||||
messages: Array<{ body: EmailMessage }>,
|
||||
options?: { contentType?: string },
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
import { adminProcedure, protectedProcedure, publicProcedure } from "../index";
|
||||
import { generateQrSecret } from "../lib/drinkkaart-utils";
|
||||
import { drinkkaartRouter } from "./drinkkaart";
|
||||
|
||||
// Reminder windows derived from the canonical registration open date
|
||||
const REMINDER_1H_WINDOW_START = new Date(
|
||||
REGISTRATION_OPENS_AT.getTime() - 60 * 60 * 1000,
|
||||
);
|
||||
const REMINDER_24H_WINDOW_START = new Date(
|
||||
REGISTRATION_OPENS_AT.getTime() - 25 * 60 * 60 * 1000,
|
||||
);
|
||||
const REMINDER_24H_WINDOW_END = new Date(
|
||||
REGISTRATION_OPENS_AT.getTime() - 23 * 60 * 60 * 1000,
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Shared helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -266,7 +308,7 @@ export const appRouter = {
|
||||
|
||||
submitRegistration: publicProcedure
|
||||
.input(submitRegistrationSchema)
|
||||
.handler(async ({ input }) => {
|
||||
.handler(async ({ input, context }) => {
|
||||
const managementToken = randomUUID();
|
||||
const isPerformer = input.registrationType === "performer";
|
||||
const guests = isPerformer ? [] : (input.guests ?? []);
|
||||
@@ -288,7 +330,8 @@ export const appRouter = {
|
||||
managementToken,
|
||||
});
|
||||
|
||||
await sendConfirmationEmail({
|
||||
const confirmationMsg: EmailMessage = {
|
||||
type: "registrationConfirmation",
|
||||
to: input.email,
|
||||
firstName: input.firstName,
|
||||
managementToken,
|
||||
@@ -296,9 +339,18 @@ export const appRouter = {
|
||||
artForm: input.artForm,
|
||||
giftAmount: input.giftAmount,
|
||||
drinkCardValue: isPerformer ? 0 : drinkCardEuros(guests.length),
|
||||
}).catch((err) =>
|
||||
console.error("Failed to send confirmation email:", err),
|
||||
);
|
||||
};
|
||||
|
||||
if (context.emailQueue) {
|
||||
await context.emailQueue.send(confirmationMsg);
|
||||
} else {
|
||||
await sendConfirmationEmail(confirmationMsg).catch((err) =>
|
||||
emailLog("error", "email.catch", {
|
||||
type: "confirmation",
|
||||
error: String(err),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true, managementToken };
|
||||
}),
|
||||
@@ -321,7 +373,7 @@ export const appRouter = {
|
||||
|
||||
updateRegistration: publicProcedure
|
||||
.input(updateRegistrationSchema)
|
||||
.handler(async ({ input }) => {
|
||||
.handler(async ({ input, context }) => {
|
||||
const row = await getActiveRegistration(input.token);
|
||||
|
||||
const isPerformer = input.registrationType === "performer";
|
||||
@@ -377,7 +429,8 @@ export const appRouter = {
|
||||
})
|
||||
.where(eq(registration.managementToken, input.token));
|
||||
|
||||
await sendUpdateEmail({
|
||||
const updateMsg: EmailMessage = {
|
||||
type: "updateConfirmation",
|
||||
to: input.email,
|
||||
firstName: input.firstName,
|
||||
managementToken: input.token,
|
||||
@@ -385,14 +438,25 @@ export const appRouter = {
|
||||
artForm: input.artForm,
|
||||
giftAmount: input.giftAmount,
|
||||
drinkCardValue: isPerformer ? 0 : drinkCardEuros(guests.length),
|
||||
}).catch((err) => console.error("Failed to send update email:", err));
|
||||
};
|
||||
|
||||
if (context.emailQueue) {
|
||||
await context.emailQueue.send(updateMsg);
|
||||
} else {
|
||||
await sendUpdateEmail(updateMsg).catch((err) =>
|
||||
emailLog("error", "email.catch", {
|
||||
type: "update",
|
||||
error: String(err),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}),
|
||||
|
||||
cancelRegistration: publicProcedure
|
||||
.input(z.object({ token: z.string().uuid() }))
|
||||
.handler(async ({ input }) => {
|
||||
.handler(async ({ input, context }) => {
|
||||
const row = await getActiveRegistration(input.token);
|
||||
|
||||
await db
|
||||
@@ -400,12 +464,22 @@ export const appRouter = {
|
||||
.set({ cancelledAt: new Date() })
|
||||
.where(eq(registration.managementToken, input.token));
|
||||
|
||||
await sendCancellationEmail({
|
||||
const cancellationMsg: EmailMessage = {
|
||||
type: "cancellation",
|
||||
to: row.email,
|
||||
firstName: row.firstName,
|
||||
}).catch((err) =>
|
||||
console.error("Failed to send cancellation email:", err),
|
||||
);
|
||||
};
|
||||
|
||||
if (context.emailQueue) {
|
||||
await context.emailQueue.send(cancellationMsg);
|
||||
} else {
|
||||
await sendCancellationEmail(cancellationMsg).catch((err) =>
|
||||
emailLog("error", "email.catch", {
|
||||
type: "cancellation",
|
||||
error: String(err),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}),
|
||||
@@ -418,7 +492,7 @@ export const appRouter = {
|
||||
if (input.search) {
|
||||
const term = `%${input.search}%`;
|
||||
conditions.push(
|
||||
and(
|
||||
or(
|
||||
like(registration.firstName, term),
|
||||
like(registration.lastName, term),
|
||||
like(registration.email, term),
|
||||
@@ -466,27 +540,49 @@ export const appRouter = {
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
const [totalResult, todayResult, artFormResult, typeResult, giftResult] =
|
||||
await Promise.all([
|
||||
db.select({ count: count() }).from(registration),
|
||||
db
|
||||
.select({ count: count() })
|
||||
.from(registration)
|
||||
.where(gte(registration.createdAt, today)),
|
||||
db
|
||||
.select({ artForm: registration.artForm, count: count() })
|
||||
.from(registration)
|
||||
.where(eq(registration.registrationType, "performer"))
|
||||
.groupBy(registration.artForm),
|
||||
db
|
||||
.select({
|
||||
registrationType: registration.registrationType,
|
||||
count: count(),
|
||||
})
|
||||
.from(registration)
|
||||
.groupBy(registration.registrationType),
|
||||
db.select({ total: sum(registration.giftAmount) }).from(registration),
|
||||
]);
|
||||
const [
|
||||
totalResult,
|
||||
todayResult,
|
||||
artFormResult,
|
||||
typeResult,
|
||||
giftResult,
|
||||
watcherGuestRows,
|
||||
] = await Promise.all([
|
||||
db.select({ count: count() }).from(registration),
|
||||
db
|
||||
.select({ count: count() })
|
||||
.from(registration)
|
||||
.where(gte(registration.createdAt, today)),
|
||||
db
|
||||
.select({ artForm: registration.artForm, count: count() })
|
||||
.from(registration)
|
||||
.where(eq(registration.registrationType, "performer"))
|
||||
.groupBy(registration.artForm),
|
||||
db
|
||||
.select({
|
||||
registrationType: registration.registrationType,
|
||||
count: count(),
|
||||
})
|
||||
.from(registration)
|
||||
.groupBy(registration.registrationType),
|
||||
db.select({ total: sum(registration.giftAmount) }).from(registration),
|
||||
// Fetch guests column for all watcher registrations to count total guests
|
||||
db
|
||||
.select({ guests: registration.guests })
|
||||
.from(registration)
|
||||
.where(
|
||||
and(
|
||||
eq(registration.registrationType, "watcher"),
|
||||
isNull(registration.cancelledAt),
|
||||
),
|
||||
),
|
||||
]);
|
||||
|
||||
// Sum up all guest counts across all watcher registrations
|
||||
const totalGuestCount = watcherGuestRows.reduce((sum, r) => {
|
||||
const guests = parseGuestsJson(r.guests);
|
||||
return sum + guests.length;
|
||||
}, 0);
|
||||
|
||||
return {
|
||||
total: totalResult[0]?.count ?? 0,
|
||||
@@ -500,6 +596,7 @@ export const appRouter = {
|
||||
count: r.count,
|
||||
})),
|
||||
totalGiftRevenue: giftResult[0]?.total ?? 0,
|
||||
totalGuestCount,
|
||||
};
|
||||
}),
|
||||
|
||||
@@ -509,6 +606,9 @@ export const appRouter = {
|
||||
.from(registration)
|
||||
.orderBy(desc(registration.createdAt));
|
||||
|
||||
const escapeCell = (val: string) => `"${val.replace(/"/g, '""')}"`;
|
||||
|
||||
// Main registration headers
|
||||
const headers = [
|
||||
"ID",
|
||||
"First Name",
|
||||
@@ -519,49 +619,97 @@ export const appRouter = {
|
||||
"Art Form",
|
||||
"Experience",
|
||||
"Is Over 16",
|
||||
"Drink Card Value",
|
||||
"Gift Amount",
|
||||
"Drink Card Value (EUR)",
|
||||
"Gift Amount (cents)",
|
||||
"Guest Count",
|
||||
"Guests",
|
||||
"Guest 1 First Name",
|
||||
"Guest 1 Last Name",
|
||||
"Guest 1 Email",
|
||||
"Guest 1 Phone",
|
||||
"Guest 2 First Name",
|
||||
"Guest 2 Last Name",
|
||||
"Guest 2 Email",
|
||||
"Guest 2 Phone",
|
||||
"Guest 3 First Name",
|
||||
"Guest 3 Last Name",
|
||||
"Guest 3 Email",
|
||||
"Guest 3 Phone",
|
||||
"Guest 4 First Name",
|
||||
"Guest 4 Last Name",
|
||||
"Guest 4 Email",
|
||||
"Guest 4 Phone",
|
||||
"Guest 5 First Name",
|
||||
"Guest 5 Last Name",
|
||||
"Guest 5 Email",
|
||||
"Guest 5 Phone",
|
||||
"Guest 6 First Name",
|
||||
"Guest 6 Last Name",
|
||||
"Guest 6 Email",
|
||||
"Guest 6 Phone",
|
||||
"Guest 7 First Name",
|
||||
"Guest 7 Last Name",
|
||||
"Guest 7 Email",
|
||||
"Guest 7 Phone",
|
||||
"Guest 8 First Name",
|
||||
"Guest 8 Last Name",
|
||||
"Guest 8 Email",
|
||||
"Guest 8 Phone",
|
||||
"Guest 9 First Name",
|
||||
"Guest 9 Last Name",
|
||||
"Guest 9 Email",
|
||||
"Guest 9 Phone",
|
||||
"Payment Status",
|
||||
"Paid At",
|
||||
"Extra Questions",
|
||||
"Cancelled At",
|
||||
"Created At",
|
||||
];
|
||||
|
||||
const MAX_GUESTS = 9;
|
||||
|
||||
const rows = data.map((r) => {
|
||||
const guests = parseGuestsJson(r.guests);
|
||||
const guestSummary = guests
|
||||
.map(
|
||||
(g) =>
|
||||
`${g.firstName} ${g.lastName}${g.email ? ` <${g.email}>` : ""}${g.phone ? ` (${g.phone})` : ""}`,
|
||||
)
|
||||
.join(" | ");
|
||||
|
||||
// Build guest columns (up to 9 guests, 4 fields each)
|
||||
const guestCols: string[] = [];
|
||||
for (let i = 0; i < MAX_GUESTS; i++) {
|
||||
const g = guests[i];
|
||||
guestCols.push(g?.firstName ?? "");
|
||||
guestCols.push(g?.lastName ?? "");
|
||||
guestCols.push(g?.email ?? "");
|
||||
guestCols.push(g?.phone ?? "");
|
||||
}
|
||||
|
||||
return [
|
||||
r.id,
|
||||
r.firstName,
|
||||
r.lastName,
|
||||
r.email,
|
||||
r.phone || "",
|
||||
r.registrationType,
|
||||
r.registrationType ?? "",
|
||||
r.artForm || "",
|
||||
r.experience || "",
|
||||
r.isOver16 ? "Yes" : "No",
|
||||
String(r.drinkCardValue ?? 0),
|
||||
String(r.giftAmount ?? 0),
|
||||
String(guests.length),
|
||||
guestSummary,
|
||||
r.paymentStatus === "paid" ? "Paid" : "Pending",
|
||||
...guestCols,
|
||||
r.paymentStatus === "paid"
|
||||
? "Paid"
|
||||
: r.paymentStatus === "extra_payment_pending"
|
||||
? "Extra Payment Pending"
|
||||
: "Pending",
|
||||
r.paidAt ? r.paidAt.toISOString() : "",
|
||||
r.extraQuestions || "",
|
||||
r.cancelledAt ? r.cancelledAt.toISOString() : "",
|
||||
r.createdAt.toISOString(),
|
||||
];
|
||||
});
|
||||
|
||||
const csvContent = [
|
||||
headers.join(","),
|
||||
headers.map(escapeCell).join(","),
|
||||
...rows.map((row) =>
|
||||
row.map((cell) => `"${String(cell).replace(/"/g, '""')}"`).join(","),
|
||||
row.map((cell) => escapeCell(String(cell))).join(","),
|
||||
),
|
||||
].join("\n");
|
||||
|
||||
@@ -729,6 +877,166 @@ export const appRouter = {
|
||||
return { success: true, message: "Admin toegang geweigerd" };
|
||||
}),
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Reminder opt-in
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Subscribe an email address to receive reminders before registration opens:
|
||||
* one 24 hours before and one 1 hour before. Silently deduplicates — if the
|
||||
* email is already subscribed, returns ok:true without error. Returns
|
||||
* ok:false if registration is already open.
|
||||
*/
|
||||
subscribeReminder: publicProcedure
|
||||
.input(z.object({ email: z.string().email() }))
|
||||
.handler(async ({ input, context }) => {
|
||||
const now = Date.now();
|
||||
|
||||
// Registration is already open — no point subscribing
|
||||
if (now >= REGISTRATION_OPENS_AT.getTime()) {
|
||||
return { ok: false, reason: "already_open" as const };
|
||||
}
|
||||
|
||||
// Check for an existing subscription (silent dedup)
|
||||
const existing = await db
|
||||
.select({ id: reminder.id })
|
||||
.from(reminder)
|
||||
.where(eq(reminder.email, input.email))
|
||||
.limit(1)
|
||||
.then((rows) => rows[0]);
|
||||
|
||||
if (existing) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
await db.insert(reminder).values({
|
||||
id: randomUUID(),
|
||||
email: input.email,
|
||||
});
|
||||
|
||||
const subMsg: EmailMessage = {
|
||||
type: "subscriptionConfirmation",
|
||||
to: input.email,
|
||||
};
|
||||
|
||||
if (context.emailQueue) {
|
||||
await context.emailQueue.send(subMsg);
|
||||
} else {
|
||||
// Awaited — CF Workers abandon unawaited promises when the response
|
||||
// returns. Mail errors are caught so they don't fail the request.
|
||||
await sendSubscriptionConfirmationEmail({ to: input.email }).catch(
|
||||
(err) =>
|
||||
emailLog("error", "email.catch", {
|
||||
type: "subscription_confirmation",
|
||||
to: input.email,
|
||||
error: String(err),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return { ok: true };
|
||||
}),
|
||||
|
||||
/**
|
||||
* Send pending reminder emails to all opted-in addresses.
|
||||
* Protected by a shared secret (`CRON_SECRET`) passed as an Authorization
|
||||
* header. Should be called by a Cloudflare Cron Trigger at the top of
|
||||
* every hour, or directly via `POST /api/cron/reminders`.
|
||||
*
|
||||
* Fires two waves:
|
||||
* - 24 hours before: window [REGISTRATION_OPENS_AT - 25h, REGISTRATION_OPENS_AT - 23h)
|
||||
* - 1 hour before: window [REGISTRATION_OPENS_AT - 1h, REGISTRATION_OPENS_AT)
|
||||
*/
|
||||
sendReminders: publicProcedure
|
||||
.input(z.object({ secret: z.string() }))
|
||||
.handler(async ({ input }) => {
|
||||
// Validate the shared secret
|
||||
if (!env.CRON_SECRET || input.secret !== env.CRON_SECRET) {
|
||||
throw new Error("Unauthorized");
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
const in24hWindow =
|
||||
now >= REMINDER_24H_WINDOW_START.getTime() &&
|
||||
now < REMINDER_24H_WINDOW_END.getTime();
|
||||
const in1hWindow =
|
||||
now >= REMINDER_1H_WINDOW_START.getTime() &&
|
||||
now < REGISTRATION_OPENS_AT.getTime();
|
||||
|
||||
const activeWindow = in24hWindow ? "24h" : in1hWindow ? "1h" : null;
|
||||
emailLog("info", "reminders.cron.tick", { activeWindow });
|
||||
|
||||
if (!in24hWindow && !in1hWindow) {
|
||||
return { sent: 0, skipped: true, reason: "outside_window" as const };
|
||||
}
|
||||
|
||||
let sent = 0;
|
||||
const errors: string[] = [];
|
||||
|
||||
if (in24hWindow) {
|
||||
// Fetch reminders where the 24h email has not been sent yet
|
||||
const pending = await db
|
||||
.select()
|
||||
.from(reminder)
|
||||
.where(isNull(reminder.sent24hAt));
|
||||
|
||||
emailLog("info", "reminders.24h.pending", { count: pending.length });
|
||||
|
||||
for (const row of pending) {
|
||||
try {
|
||||
await sendReminder24hEmail({ to: row.email });
|
||||
await db
|
||||
.update(reminder)
|
||||
.set({ sent24hAt: new Date() })
|
||||
.where(eq(reminder.id, row.id));
|
||||
sent++;
|
||||
} catch (err) {
|
||||
errors.push(`24h ${row.email}: ${String(err)}`);
|
||||
emailLog("error", "email.catch", {
|
||||
type: "reminder_24h",
|
||||
to: row.email,
|
||||
error: String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in1hWindow) {
|
||||
// Fetch reminders where the 1h email has not been sent yet
|
||||
const pending = await db
|
||||
.select()
|
||||
.from(reminder)
|
||||
.where(isNull(reminder.sentAt));
|
||||
|
||||
emailLog("info", "reminders.1h.pending", { count: pending.length });
|
||||
|
||||
for (const row of pending) {
|
||||
try {
|
||||
await sendReminderEmail({ to: row.email });
|
||||
await db
|
||||
.update(reminder)
|
||||
.set({ sentAt: new Date() })
|
||||
.where(eq(reminder.id, row.id));
|
||||
sent++;
|
||||
} catch (err) {
|
||||
errors.push(`1h ${row.email}: ${String(err)}`);
|
||||
emailLog("error", "email.catch", {
|
||||
type: "reminder_1h",
|
||||
to: row.email,
|
||||
error: String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emailLog("info", "reminders.cron.done", {
|
||||
sent,
|
||||
errorCount: errors.length,
|
||||
});
|
||||
|
||||
return { sent, skipped: false, errors };
|
||||
}),
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Checkout
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -835,3 +1143,181 @@ export const appRouter = {
|
||||
|
||||
export type AppRouter = typeof appRouter;
|
||||
export type AppRouterClient = RouterClient<typeof appRouter>;
|
||||
|
||||
/**
|
||||
* Standalone function that sends pending reminder emails.
|
||||
* Exported so that the Cloudflare Cron HTTP handler can call it directly
|
||||
* without needing drizzle-orm as a direct dependency of apps/web.
|
||||
*
|
||||
* When `emailQueue` is provided, reminder fan-outs mark the DB rows
|
||||
* optimistically before calling `sendBatch()` — preventing re-enqueue on
|
||||
* the next cron tick while still letting the queue handle email delivery
|
||||
* and retries. Payment reminders always run directly since they need
|
||||
* per-row DB updates tightly coupled to the send.
|
||||
*/
|
||||
export async function runSendReminders(emailQueue?: EmailQueue): Promise<{
|
||||
sent: number;
|
||||
skipped: boolean;
|
||||
reason?: string;
|
||||
errors: string[];
|
||||
}> {
|
||||
const now = Date.now();
|
||||
const in24hWindow =
|
||||
now >= REMINDER_24H_WINDOW_START.getTime() &&
|
||||
now < REMINDER_24H_WINDOW_END.getTime();
|
||||
const in1hWindow =
|
||||
now >= REMINDER_1H_WINDOW_START.getTime() &&
|
||||
now < REGISTRATION_OPENS_AT.getTime();
|
||||
|
||||
const activeWindow = in24hWindow ? "24h" : in1hWindow ? "1h" : null;
|
||||
emailLog("info", "reminders.cron.tick", { activeWindow });
|
||||
|
||||
if (!in24hWindow && !in1hWindow) {
|
||||
return { sent: 0, skipped: true, reason: "outside_window", errors: [] };
|
||||
}
|
||||
|
||||
let sent = 0;
|
||||
const errors: string[] = [];
|
||||
|
||||
if (in24hWindow) {
|
||||
const pending = await db
|
||||
.select()
|
||||
.from(reminder)
|
||||
.where(isNull(reminder.sent24hAt));
|
||||
|
||||
emailLog("info", "reminders.24h.pending", { count: pending.length });
|
||||
|
||||
if (emailQueue && pending.length > 0) {
|
||||
// Mark rows optimistically before enqueuing — prevents re-enqueue on the
|
||||
// next cron tick if the queue send succeeds but the consumer hasn't run yet.
|
||||
for (const row of pending) {
|
||||
await db
|
||||
.update(reminder)
|
||||
.set({ sent24hAt: new Date() })
|
||||
.where(eq(reminder.id, row.id));
|
||||
}
|
||||
await emailQueue.sendBatch(
|
||||
pending.map((row) => ({
|
||||
body: {
|
||||
type: "reminder24h" as const,
|
||||
to: row.email,
|
||||
} satisfies EmailMessage,
|
||||
})),
|
||||
);
|
||||
sent += pending.length;
|
||||
} else {
|
||||
for (const row of pending) {
|
||||
try {
|
||||
await sendReminder24hEmail({ to: row.email });
|
||||
await db
|
||||
.update(reminder)
|
||||
.set({ sent24hAt: new Date() })
|
||||
.where(eq(reminder.id, row.id));
|
||||
sent++;
|
||||
} catch (err) {
|
||||
errors.push(`24h ${row.email}: ${String(err)}`);
|
||||
emailLog("error", "email.catch", {
|
||||
type: "reminder_24h",
|
||||
to: row.email,
|
||||
error: String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (in1hWindow) {
|
||||
const pending = await db
|
||||
.select()
|
||||
.from(reminder)
|
||||
.where(isNull(reminder.sentAt));
|
||||
|
||||
emailLog("info", "reminders.1h.pending", { count: pending.length });
|
||||
|
||||
if (emailQueue && pending.length > 0) {
|
||||
// Mark rows optimistically before enqueuing — prevents re-enqueue on the
|
||||
// next cron tick if the queue send succeeds but the consumer hasn't run yet.
|
||||
for (const row of pending) {
|
||||
await db
|
||||
.update(reminder)
|
||||
.set({ sentAt: new Date() })
|
||||
.where(eq(reminder.id, row.id));
|
||||
}
|
||||
await emailQueue.sendBatch(
|
||||
pending.map((row) => ({
|
||||
body: {
|
||||
type: "reminder1h" as const,
|
||||
to: row.email,
|
||||
} satisfies EmailMessage,
|
||||
})),
|
||||
);
|
||||
sent += pending.length;
|
||||
} else {
|
||||
for (const row of pending) {
|
||||
try {
|
||||
await sendReminderEmail({ to: row.email });
|
||||
await db
|
||||
.update(reminder)
|
||||
.set({ sentAt: new Date() })
|
||||
.where(eq(reminder.id, row.id));
|
||||
sent++;
|
||||
} catch (err) {
|
||||
errors.push(`1h ${row.email}: ${String(err)}`);
|
||||
emailLog("error", "email.catch", {
|
||||
type: "reminder_1h",
|
||||
to: row.email,
|
||||
error: String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Payment reminders: watchers with pending payment older than 3 days.
|
||||
// Always run directly (not via queue) — each row needs a DB update after send.
|
||||
const threeDaysAgo = now - 3 * 24 * 60 * 60 * 1000;
|
||||
const unpaidWatchers = await db
|
||||
.select()
|
||||
.from(registration)
|
||||
.where(
|
||||
and(
|
||||
eq(registration.registrationType, "watcher"),
|
||||
eq(registration.paymentStatus, "pending"),
|
||||
isNull(registration.paymentReminderSentAt),
|
||||
lte(registration.createdAt, new Date(threeDaysAgo)),
|
||||
),
|
||||
);
|
||||
|
||||
emailLog("info", "reminders.payment.pending", {
|
||||
count: unpaidWatchers.length,
|
||||
});
|
||||
|
||||
for (const reg of unpaidWatchers) {
|
||||
if (!reg.managementToken) continue;
|
||||
try {
|
||||
await sendPaymentReminderEmail({
|
||||
to: reg.email,
|
||||
firstName: reg.firstName,
|
||||
managementToken: reg.managementToken,
|
||||
drinkCardValue: reg.drinkCardValue ?? undefined,
|
||||
giftAmount: reg.giftAmount ?? undefined,
|
||||
});
|
||||
await db
|
||||
.update(registration)
|
||||
.set({ paymentReminderSentAt: new Date() })
|
||||
.where(eq(registration.id, reg.id));
|
||||
sent++;
|
||||
} catch (err) {
|
||||
errors.push(`payment-reminder ${reg.email}: ${String(err)}`);
|
||||
emailLog("error", "email.catch", {
|
||||
type: "payment_reminder",
|
||||
to: reg.email,
|
||||
error: String(err),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
emailLog("info", "reminders.cron.done", { sent, errorCount: errors.length });
|
||||
|
||||
return { sent, skipped: false, errors };
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
"@kk/env": "workspace:*",
|
||||
"better-auth": "catalog:",
|
||||
"dotenv": "catalog:",
|
||||
"nodemailer": "^8.0.2",
|
||||
"zod": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kk/config": "workspace:*",
|
||||
"@types/nodemailer": "^7.0.11",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,96 @@ import { env } from "@kk/env/server";
|
||||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
import { tanstackStartCookies } from "better-auth/tanstack-start";
|
||||
import nodemailer from "nodemailer";
|
||||
|
||||
const _smtpFrom = env.SMTP_FROM ?? "Kunstenkamp <info@kunstenkamp.be>";
|
||||
|
||||
let _transport: nodemailer.Transporter | null | undefined;
|
||||
function getTransport(): nodemailer.Transporter | null {
|
||||
if (_transport !== undefined) return _transport;
|
||||
if (!env.SMTP_HOST || !env.SMTP_USER || !env.SMTP_PASS) {
|
||||
_transport = null;
|
||||
return null;
|
||||
}
|
||||
_transport = nodemailer.createTransport({
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
secure: env.SMTP_PORT === 465,
|
||||
auth: { user: env.SMTP_USER, pass: env.SMTP_PASS },
|
||||
});
|
||||
return _transport;
|
||||
}
|
||||
|
||||
async function sendPasswordResetEmail(to: string, resetUrl: string) {
|
||||
const transport = getTransport();
|
||||
if (!transport) {
|
||||
console.warn("SMTP not configured — skipping password reset email");
|
||||
return;
|
||||
}
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="nl">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Wachtwoord opnieuw instellen</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background:#f4f4f5;font-family:sans-serif;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background:#f4f4f5;padding:40px 0;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table width="600" cellpadding="0" cellspacing="0" style="background:#214e51;border-radius:4px;overflow:hidden;">
|
||||
<tr>
|
||||
<td style="padding:40px 48px 32px;">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.5);letter-spacing:0.08em;text-transform:uppercase;">Kunstenkamp</p>
|
||||
<h1 style="margin:12px 0 0;font-size:28px;color:#ffffff;font-weight:700;">Wachtwoord opnieuw instellen</h1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:0 48px 32px;">
|
||||
<p style="margin:0 0 16px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
We hebben een aanvraag ontvangen om het wachtwoord van je Kunstenkamp-account opnieuw in te stellen.
|
||||
</p>
|
||||
<p style="margin:0 0 24px;font-size:16px;color:rgba(255,255,255,0.85);line-height:1.6;">
|
||||
Klik op de knop hieronder om een nieuw wachtwoord in te stellen. Deze link is <strong style="color:#ffffff;">1 uur geldig</strong>.
|
||||
</p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td style="border-radius:2px;background:#ffffff;">
|
||||
<a href="${resetUrl}" style="display:inline-block;padding:14px 32px;font-size:16px;font-weight:600;color:#214e51;text-decoration:none;">
|
||||
Stel wachtwoord in
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="margin:16px 0 0;font-size:13px;color:rgba(255,255,255,0.4);">
|
||||
Of kopieer deze link: <span style="color:rgba(255,255,255,0.6);">${resetUrl}</span>
|
||||
</p>
|
||||
<p style="margin:24px 0 0;font-size:14px;color:rgba(255,255,255,0.5);line-height:1.6;">
|
||||
Heb je dit niet aangevraagd? Dan hoef je niets te doen — je wachtwoord blijft ongewijzigd.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:24px 48px;border-top:1px solid rgba(255,255,255,0.1);">
|
||||
<p style="margin:0;font-size:13px;color:rgba(255,255,255,0.4);line-height:1.6;">
|
||||
Vragen? Mail ons op <a href="mailto:info@kunstenkamp.be" style="color:rgba(255,255,255,0.6);">info@kunstenkamp.be</a><br/>
|
||||
Kunstenkamp vzw — Een initiatief voor en door kunstenaars.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
await transport.sendMail({
|
||||
from: _smtpFrom,
|
||||
to,
|
||||
subject: "Wachtwoord opnieuw instellen — Kunstenkamp",
|
||||
html,
|
||||
});
|
||||
}
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: drizzleAdapter(db, {
|
||||
@@ -35,6 +125,9 @@ export const auth = betterAuth({
|
||||
return keyBuffer.equals(hashBuffer);
|
||||
},
|
||||
},
|
||||
sendResetPassword: async ({ user, url }) => {
|
||||
await sendPasswordResetEmail(user.email, url);
|
||||
},
|
||||
},
|
||||
user: {
|
||||
additionalFields: {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
packages/db/src/migrations/0007_reminder.sql
Normal file
9
packages/db/src/migrations/0007_reminder.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Add reminder table for email reminders 1 hour before registration opens
|
||||
CREATE TABLE `reminder` (
|
||||
`id` text PRIMARY KEY NOT NULL,
|
||||
`email` text NOT NULL,
|
||||
`sent_at` integer,
|
||||
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX `reminder_email_idx` ON `reminder` (`email`);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Migration: add payment_reminder_sent_at column to registration table
|
||||
ALTER TABLE registration ADD COLUMN payment_reminder_sent_at INTEGER;
|
||||
2
packages/db/src/migrations/0009_reminder_24h.sql
Normal file
2
packages/db/src/migrations/0009_reminder_24h.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- Add sent_24h_at column to track whether the 24-hour-before reminder was sent
|
||||
ALTER TABLE `reminder` ADD `sent_24h_at` integer;
|
||||
@@ -29,6 +29,34 @@
|
||||
"when": 1772530000000,
|
||||
"tag": "0003_add_guests",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "6",
|
||||
"when": 1772536320000,
|
||||
"tag": "0004_drinkkaart",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "6",
|
||||
"when": 1772596240000,
|
||||
"tag": "0005_registration_drinkkaart_credit",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "6",
|
||||
"when": 1772672880000,
|
||||
"tag": "0006_mollie_migration",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "6",
|
||||
"when": 1772931300000,
|
||||
"tag": "0007_reminder",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ export * from "./admin-requests";
|
||||
export * from "./auth";
|
||||
export * from "./drinkkaart";
|
||||
export * from "./registrations";
|
||||
export * from "./reminders";
|
||||
|
||||
@@ -37,6 +37,9 @@ export const registration = sqliteTable(
|
||||
drinkkaartCreditedAt: integer("drinkkaart_credited_at", {
|
||||
mode: "timestamp_ms",
|
||||
}),
|
||||
paymentReminderSentAt: integer("payment_reminder_sent_at", {
|
||||
mode: "timestamp_ms",
|
||||
}),
|
||||
createdAt: integer("created_at", { mode: "timestamp_ms" })
|
||||
.default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)
|
||||
.notNull(),
|
||||
|
||||
21
packages/db/src/schema/reminders.ts
Normal file
21
packages/db/src/schema/reminders.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { sql } from "drizzle-orm";
|
||||
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||
|
||||
export const reminder = sqliteTable(
|
||||
"reminder",
|
||||
{
|
||||
id: text("id").primaryKey(), // UUID
|
||||
email: text("email").notNull(),
|
||||
/** Set when the 24-hours-before reminder has been sent. */
|
||||
sent24hAt: integer("sent_24h_at", { mode: "timestamp_ms" }),
|
||||
/** Set when the 1-hour-before reminder has been sent. */
|
||||
sentAt: integer("sent_at", { mode: "timestamp_ms" }),
|
||||
createdAt: integer("created_at", { mode: "timestamp_ms" })
|
||||
.default(sql`(cast(unixepoch('subsecond') * 1000 as integer))`)
|
||||
.notNull(),
|
||||
},
|
||||
(t) => [index("reminder_email_idx").on(t.email)],
|
||||
);
|
||||
|
||||
export type Reminder = typeof reminder.$inferSelect;
|
||||
export type NewReminder = typeof reminder.$inferInsert;
|
||||
5
packages/env/src/server.ts
vendored
5
packages/env/src/server.ts
vendored
@@ -15,17 +15,18 @@ export const env = createEnv({
|
||||
server: {
|
||||
DATABASE_URL: z.string().min(1),
|
||||
BETTER_AUTH_SECRET: z.string().min(32),
|
||||
BETTER_AUTH_URL: z.url(),
|
||||
BETTER_AUTH_URL: z.url().default("https://kunstenkamp.be"),
|
||||
CORS_ORIGIN: z.url(),
|
||||
SMTP_HOST: z.string().min(1).optional(),
|
||||
SMTP_PORT: z.coerce.number().default(587),
|
||||
SMTP_USER: z.string().min(1).optional(),
|
||||
SMTP_PASS: z.string().min(1).optional(),
|
||||
SMTP_FROM: z.string().min(1).optional(),
|
||||
SMTP_FROM: z.string().min(1).default("Kunstenkamp <info@kunstenkamp.be>"),
|
||||
NODE_ENV: z
|
||||
.enum(["development", "production", "test"])
|
||||
.default("development"),
|
||||
MOLLIE_API_KEY: z.string().min(1).optional(),
|
||||
CRON_SECRET: z.string().min(1).optional(),
|
||||
},
|
||||
runtimeEnv: process.env,
|
||||
emptyStringAsUndefined: true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import alchemy from "alchemy";
|
||||
import { TanStackStart } from "alchemy/cloudflare";
|
||||
import { Queue, TanStackStart } from "alchemy/cloudflare";
|
||||
import { config } from "dotenv";
|
||||
|
||||
config({ path: "./.env" });
|
||||
@@ -16,6 +16,10 @@ function getEnvVar(name: string): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
const emailQueue = await Queue("email-queue", {
|
||||
name: "kk-email-queue",
|
||||
});
|
||||
|
||||
export const web = await TanStackStart("web", {
|
||||
cwd: "../../apps/web",
|
||||
bindings: {
|
||||
@@ -32,7 +36,25 @@ export const web = await TanStackStart("web", {
|
||||
SMTP_FROM: getEnvVar("SMTP_FROM"),
|
||||
// Payments (Mollie)
|
||||
MOLLIE_API_KEY: getEnvVar("MOLLIE_API_KEY"),
|
||||
// Cron secret for protected scheduled endpoints
|
||||
CRON_SECRET: getEnvVar("CRON_SECRET"),
|
||||
// Queue binding for async email sends
|
||||
EMAIL_QUEUE: emailQueue,
|
||||
},
|
||||
// Queue consumer: the worker's queue() handler processes EmailMessage batches
|
||||
eventSources: [
|
||||
{
|
||||
queue: emailQueue,
|
||||
settings: {
|
||||
batchSize: 10,
|
||||
maxRetries: 3,
|
||||
retryDelay: 60, // seconds before retrying a failed message
|
||||
maxWaitTimeMs: 1000,
|
||||
},
|
||||
},
|
||||
],
|
||||
// Fire every hour so reminder checks can run at 19:00 on 2026-03-15 (24h) and 18:00 on 2026-03-16 (1h)
|
||||
crons: ["0 * * * *"],
|
||||
domains: ["kunstenkamp.be", "www.kunstenkamp.be"],
|
||||
});
|
||||
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
"persistent": true
|
||||
},
|
||||
"db:push": {
|
||||
"cache": false
|
||||
"cache": false,
|
||||
"interactive": true
|
||||
},
|
||||
"db:generate": {
|
||||
"cache": false
|
||||
"cache": false,
|
||||
"interactive": true
|
||||
},
|
||||
"db:migrate": {
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
"persistent": true,
|
||||
"interactive": true
|
||||
},
|
||||
"db:studio": {
|
||||
"cache": false,
|
||||
|
||||
Reference in New Issue
Block a user