2026-11-17 18:37:15 +00:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
|
|
|
|
|
import { api, errorText } from "@/lib/api";
|
|
|
|
|
|
|
|
|
|
// A button, not an automatic request: link scanners of mail providers open
|
|
|
|
|
// every link, and they must not unsubscribe anyone.
|
|
|
|
|
export function Unsubscribe({ token }: { token: string | null }) {
|
|
|
|
|
const [state, setState] = useState<"idle" | "busy" | "done">("idle");
|
|
|
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
if (!token) {
|
|
|
|
|
return (
|
|
|
|
|
<p className="msg msg-error" role="alert">
|
|
|
|
|
Hiányzik a link vége. Nyisd meg a teljes linket a levélből.
|
|
|
|
|
</p>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (state === "done") {
|
|
|
|
|
return (
|
|
|
|
|
<p className="msg msg-ok" role="status">
|
2026-11-19 11:07:13 +00:00
|
|
|
Leiratkoztál: erre a címre nem küldünk több meghívót, és levettük a várólistáról.
|
2026-11-17 18:37:15 +00:00
|
|
|
</p>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function confirm() {
|
|
|
|
|
setState("busy");
|
|
|
|
|
setError(null);
|
|
|
|
|
try {
|
|
|
|
|
await api(`/public/invitations/unsubscribe?token=${encodeURIComponent(token!)}`, { method: "POST" });
|
|
|
|
|
setState("done");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
setError(errorText(e));
|
|
|
|
|
setState("idle");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="card field" style={{ gap: 12 }}>
|
|
|
|
|
<p style={{ margin: 0 }}>
|
2026-11-19 11:07:13 +00:00
|
|
|
Ha leiratkozol, erre az e-mail-címre többé nem küldünk meghívót, levesszük a várólistáról, és a mostani meghívód
|
|
|
|
|
is érvényét veszti.
|
2026-11-17 18:37:15 +00:00
|
|
|
</p>
|
|
|
|
|
<div>
|
|
|
|
|
<button type="button" className="btn btn-primary" onClick={confirm} disabled={state === "busy"}>
|
|
|
|
|
{state === "busy" ? "Leiratkozás…" : "Leiratkozom"}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
{error && (
|
|
|
|
|
<p className="msg msg-error" role="alert">
|
|
|
|
|
{error}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|