Inviting shown but off until launch; waitlist confirmation; waitlist invites with a package
CI / test (push) Successful in 1m35s
CI / build (push) Successful in 8m7s
CI / deploy (push) Skipped

USER_INVITES (default false) keeps users from inviting others until the
launch: the 'Meghívom' option and a 'Hívd meg, akit szeretsz' card on the
persons page are shown, disabled, with 'Hamarosan'; the backend refuses
with invites_disabled (admins may always).

Joining the waitlist sends one confirmation e-mail (waitlist_joined) with a
link that takes the address off the list and opts it out; at most 10 per
address in 15 minutes. Admins can pick a package for waitlist invitations,
like on the invitation form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-19 11:07:13 +00:00
co-authored by Claude Opus 5.5
parent dad16fe463
commit 8e1205359d
18 changed files with 285 additions and 26 deletions
@@ -0,0 +1,3 @@
-- The link in the waitlist confirmation e-mail that takes the address off
-- the list (only its hash is kept).
ALTER TABLE waitlist ADD COLUMN token_hash bytea UNIQUE;
+63
View File
@@ -159,6 +159,7 @@ pub fn render(template: &str, locale: &str, payload: &Value) -> Result<Rendered,
} }
("invitation", _) => invitation(lang, payload, url)?, ("invitation", _) => invitation(lang, payload, url)?,
("synastry_invite", _) => synastry_invite(lang, payload, url)?, ("synastry_invite", _) => synastry_invite(lang, payload, url)?,
("waitlist_joined", _) => waitlist_joined(lang, payload, url)?,
_ => return Err(TemplateError::UnknownTemplate(template.to_owned())), _ => return Err(TemplateError::UnknownTemplate(template.to_owned())),
}; };
Ok(content.render(lang)) Ok(content.render(lang))
@@ -283,6 +284,56 @@ fn name(payload: &Value, field: &str) -> Option<String> {
(!name.is_empty()).then(|| name.to_owned()) (!name.is_empty()).then(|| name.to_owned())
} }
/// The confirmation of a waitlist sign-up, with the link that takes the address off the list.
fn waitlist_joined(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> {
let unsubscribe_url = field(payload, "unsubscribe_url")?;
let unsubscribe_post_url = field(payload, "unsubscribe_post_url")?;
Ok(match lang {
Lang::Hu => Content {
subject: "Felírtunk a Sorsfonalak várólistájára".into(),
preheader: Some("Amint bejuthatsz, ide írunk.".into()),
greeting: "Szia!".into(),
intro: "Köszönjük, hogy kíváncsi vagy a Sorsfonalakra! Az oldal egyelőre zártkörű, de felírtunk a várólistára: amint bejuthatsz, erre a címre írunk."
.into(),
quote: None,
points: Some((
"Mi vár rád?",
vec![
"a születési képleted percre pontosan kiszámolva és megrajzolva, egy rövid elemzéssel,",
"részletes elemzés, éves előrejelzés és kapcsolati összevetés azokkal, akiket szeretsz.",
],
)),
button: "Körülnézek",
url,
note: "Ha nem te iratkoztál fel, vagy meggondoltad magad, a lenti linkkel törölheted a címed a listáról.".into(),
reason: Some("Ezt a levelet azért kaptad, mert ezt a címet megadták a Sorsfonalak várólistáján.".into()),
unsubscribe: Some(("Leiratkozás a várólistáról", unsubscribe_url)),
unsubscribe_post_url: Some(unsubscribe_post_url),
},
Lang::En => Content {
subject: "You are on the Sorsfonalak waitlist".into(),
preheader: Some("We will write as soon as you can get in.".into()),
greeting: "Hi,".into(),
intro: "Thanks for your interest in Sorsfonalak! The site is invitation-only for now, but you are on the waitlist: we will write to this address as soon as you can get in."
.into(),
quote: None,
points: Some((
"What awaits you:",
vec![
"your birth chart, calculated to the minute and drawn, with a short reading,",
"detailed readings, a yearly forecast and comparisons with the people you love.",
],
)),
button: "Take a look",
url,
note: "If it was not you, or you changed your mind, the link below takes your address off the list.".into(),
reason: Some("You got this e-mail because this address was entered on the Sorsfonalak waitlist.".into()),
unsubscribe: Some(("Leave the waitlist", unsubscribe_url)),
unsubscribe_post_url: Some(unsubscribe_post_url),
},
})
}
/// A user invites someone to compare their charts ("how compatible are we?"). /// A user invites someone to compare their charts ("how compatible are we?").
fn synastry_invite(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> { fn synastry_invite(lang: Lang, payload: &Value, url: String) -> Result<Content, TemplateError> {
let inviter = name(payload, "inviter_name"); let inviter = name(payload, "inviter_name");
@@ -539,6 +590,18 @@ mod tests {
}) })
} }
#[test]
fn waitlist_confirmation_has_the_leave_link() {
let hu = render("waitlist_joined", "hu", &invitation_payload()).unwrap();
assert_eq!(hu.subject, "Felírtunk a Sorsfonalak várólistájára");
assert!(
hu.text.contains("Leiratkozás a várólistáról: https://sorsfonalak.test/leiratkozas?token=abc"),
"{}",
hu.text
);
assert!(hu.unsubscribe_post_url.is_some());
}
#[test] #[test]
fn synastry_invite_names_the_inviter() { fn synastry_invite_names_the_inviter() {
let hu = render("synastry_invite", "hu", &invitation_payload()).unwrap(); let hu = render("synastry_invite", "hu", &invitation_payload()).unwrap();
+2
View File
@@ -88,6 +88,8 @@ services:
# Purchases are off until real payments are connected; packages come # Purchases are off until real payments are connected; packages come
# from promo codes and admins (MOCK_PAYMENTS=true: pretend purchases). # from promo codes and admins (MOCK_PAYMENTS=true: pretend purchases).
MOCK_PAYMENTS: ${MOCK_PAYMENTS:-false} MOCK_PAYMENTS: ${MOCK_PAYMENTS:-false}
# Users inviting others ("Meghívom"): shown but off until the launch.
USER_INVITES: ${USER_INVITES:-false}
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0} FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
# invite: new accounts need an invitation (admin page "Meghívók"); open: anyone. # invite: new accounts need an invitation (admin page "Meghívók"); open: anyone.
SIGNUP_MODE: ${SIGNUP_MODE:-invite} SIGNUP_MODE: ${SIGNUP_MODE:-invite}
+7
View File
@@ -39,6 +39,13 @@ Az Admin → Meghívók oldalon az „Ajándék csomag” választóval minden m
- **Újraküldéskor** a levélben ugyanaz a kód marad. - **Újraküldéskor** a levélben ugyanaz a kód marad.
- **Visszavonás:** a meghívó visszavonása a még fel nem használt kódot is visszavonja. - **Visszavonás:** a meghívó visszavonása a még fel nem használt kódot is visszavonja.
- **A meghívók listájában** látszik a csomag, és hogy beváltották-e. - **A meghívók listájában** látszik a csomag, és hogy beváltották-e.
- **A várólistán lévőket** is csomaggal lehet meghívni: a „Várólista” táblázat fölötti választóval a „Meghívás” gomb azzal a csomaggal küldi a meghívót.
## Várólista
- **Visszaigazolás:** aki feliratkozik, egyszer kap egy visszaigazoló levelet (`waitlist_joined`), benne leiratkozó linkkel.
- **Leiratkozás:** a link leveszi a címet a listáról, és felveszi a „nem kér levelet” listára, így meghívót sem küldünk oda többet.
- **Korlát:** IP-címenként 15 percen belül legfeljebb 10 levél megy ki, hogy az űrlappal ne lehessen mások postafiókját elárasztani. A lista legfeljebb 10 000 cím.
## API ## API
+2
View File
@@ -5,6 +5,8 @@ Az „Új személy” oldalon két lehetőség van:
- **Adatok megadása:** a felhasználó maga írja be a születési adatokat. Ez egy személyhelyet használ, ahogy eddig. - **Adatok megadása:** a felhasználó maga írja be a születési adatokat. Ez egy személyhelyet használ, ahogy eddig.
- **Meghívom:** egy „Mennyire illünk össze?” meghívó (`synastry_invites`). A meghívott a saját adatait adja meg. Személyhely nem kell hozzá, és akkor is működik, ha a helyek elfogytak. - **Meghívom:** egy „Mennyire illünk össze?” meghívó (`synastry_invites`). A meghívott a saját adatait adja meg. Személyhely nem kell hozzá, és akkor is működik, ha a helyek elfogytak.
**Az élesítésig ki van kapcsolva:** a „Meghívom” lehetőség és a Személyek oldal „Hívd meg, akit szeretsz” kártyája látszik, de „Hamarosan” felirattal le van tiltva. A backend `invites_disabled` hibával utasítja el. Bekapcsolás: `USER_INVITES=true` a szerver `.env` fájljában. Az adminok a kapcsolótól függetlenül meghívhatnak, hogy ki tudják próbálni.
## Menete ## Menete
1. **A meghívó elkészül.** A meghívó megadhatja, kinek szól (ezt csak ő látja), a meghívott e-mail-címét (nem kötelező) és egy üzenetet (legfeljebb 300 karakter, link nélkül). A link `/meghivas/<kód>`, 14 napig érvényes. Megosztható másolással, a telefon megosztás menüjével, WhatsAppon vagy Facebookon. 1. **A meghívó elkészül.** A meghívó megadhatja, kinek szól (ezt csak ő látja), a meghívott e-mail-címét (nem kötelező) és egy üzenetet (legfeljebb 300 karakter, link nélkül). A link `/meghivas/<kód>`, 14 napig érvényes. Megosztható másolással, a telefon megosztás menüjével, WhatsAppon vagy Facebookon.
+6
View File
@@ -45,6 +45,10 @@ pub struct Config {
/// `MOCK_PAYMENTS` (default `false`): a stand-in payment that adds an /// `MOCK_PAYMENTS` (default `false`): a stand-in payment that adds an
/// analysis unit at once, until Stripe is connected. /// analysis unit at once, until Stripe is connected.
pub mock_payments: bool, pub mock_payments: bool,
/// `USER_INVITES` (default `false`): users may invite others ("how
/// compatible are we?" links, which also let the invitee sign up). Off
/// until the launch; admins may always.
pub user_invites: bool,
/// `GOOGLE_CLIENT_IDS`: comma-separated OAuth client ids accepted as the /// `GOOGLE_CLIENT_IDS`: comma-separated OAuth client ids accepted as the
/// ID token audience; empty disables Google login. /// ID token audience; empty disables Google login.
pub google_client_ids: Vec<String>, pub google_client_ids: Vec<String>,
@@ -119,6 +123,7 @@ impl Config {
session_ttl_days: parsed("SESSION_TTL_DAYS", 30)?, session_ttl_days: parsed("SESSION_TTL_DAYS", 30)?,
password_login: parsed("PASSWORD_LOGIN", false)?, password_login: parsed("PASSWORD_LOGIN", false)?,
mock_payments: parsed("MOCK_PAYMENTS", false)?, mock_payments: parsed("MOCK_PAYMENTS", false)?,
user_invites: parsed("USER_INVITES", false)?,
google_client_ids: list("GOOGLE_CLIENT_IDS"), google_client_ids: list("GOOGLE_CLIENT_IDS"),
google_jwks_url: var("GOOGLE_JWKS_URL") google_jwks_url: var("GOOGLE_JWKS_URL")
.unwrap_or_else(|| "https://www.googleapis.com/oauth2/v3/certs".into()), .unwrap_or_else(|| "https://www.googleapis.com/oauth2/v3/certs".into()),
@@ -156,6 +161,7 @@ impl Config {
session_ttl_days: 30, session_ttl_days: 30,
password_login: true, password_login: true,
mock_payments: true, mock_payments: true,
user_invites: true,
google_client_ids: vec!["test-client.apps.googleusercontent.com".into()], google_client_ids: vec!["test-client.apps.googleusercontent.com".into()],
google_jwks_url, google_jwks_url,
bootstrap_admin_emails: vec!["admin@example.com".into()], bootstrap_admin_emails: vec!["admin@example.com".into()],
+35 -5
View File
@@ -587,10 +587,12 @@ pub async fn unsubscribe(
WithRejection(Query(q), _): WithRejection<Query<TokenQuery>, ApiError>, WithRejection(Query(q), _): WithRejection<Query<TokenQuery>, ApiError>,
) -> ApiResult<Json<Value>> { ) -> ApiResult<Json<Value>> {
let mut tx = state.db.begin().await?; let mut tx = state.db.begin().await?;
// The link of a site invitation, or of a "how compatible are we?" one a user had us e-mail. // The link of a site invitation, of a "how compatible are we?" one a user
// had us e-mail, or of the waitlist confirmation.
let email: Option<String> = sqlx::query_scalar( let email: Option<String> = sqlx::query_scalar(
"SELECT i.email FROM invitation_tokens t JOIN invitations i ON i.id = t.invitation_id WHERE t.token_hash = $1 \ "SELECT i.email FROM invitation_tokens t JOIN invitations i ON i.id = t.invitation_id WHERE t.token_hash = $1 \
UNION ALL SELECT invitee_email FROM synastry_invites WHERE token_hash = $1 AND invitee_email IS NOT NULL \ UNION ALL SELECT invitee_email FROM synastry_invites WHERE token_hash = $1 AND invitee_email IS NOT NULL \
UNION ALL SELECT email FROM waitlist WHERE token_hash = $1 \
LIMIT 1", LIMIT 1",
) )
.bind(db::token_hash(q.token.trim())) .bind(db::token_hash(q.token.trim()))
@@ -607,6 +609,7 @@ pub async fn unsubscribe(
.bind(&email) .bind(&email)
.execute(&mut *tx) .execute(&mut *tx)
.await?; .await?;
sqlx::query("DELETE FROM waitlist WHERE email = $1").bind(&email).execute(&mut *tx).await?;
tx.commit().await?; tx.commit().await?;
Ok(Json(json!({ "unsubscribed": true }))) Ok(Json(json!({ "unsubscribed": true })))
} }
@@ -621,19 +624,46 @@ pub struct WaitlistRequest {
/// Joins the waitlist. Always answers the same, so it does not reveal who has an account. /// Joins the waitlist. Always answers the same, so it does not reveal who has an account.
pub async fn join_waitlist( pub async fn join_waitlist(
State(state): St, State(state): St,
headers: axum::http::HeaderMap,
WithRejection(Json(req), _): Body<WaitlistRequest>, WithRejection(Json(req), _): Body<WaitlistRequest>,
) -> ApiResult<(StatusCode, Json<Value>)> { ) -> ApiResult<(StatusCode, Json<Value>)> {
let email = normalize_email(&req.email)?; let email = normalize_email(&req.email)?;
let locale = validate_locale(&state, req.locale.as_deref())?; let locale = validate_locale(&state, req.locale.as_deref())?;
sqlx::query( // Every sign-up sends an e-mail: a few per address, so the form cannot be used to flood someone.
"INSERT INTO waitlist (email, locale) SELECT $1, $2 \ let ip = headers
.get("x-forwarded-for")
.and_then(|v| v.to_str().ok())
.and_then(|v| v.split(',').next())
.map(str::trim)
.unwrap_or("unknown");
let key = format!("waitlist:{ip}");
state.login_limiter.check(&key)?;
let token = db::new_token();
let mut tx = state.db.begin().await?;
let added = sqlx::query(
"INSERT INTO waitlist (email, locale, token_hash) SELECT $1, $2, $3 \
WHERE NOT EXISTS (SELECT 1 FROM users WHERE email = $1) \ WHERE NOT EXISTS (SELECT 1 FROM users WHERE email = $1) \
AND (SELECT count(*) FROM waitlist) < 10000 \ AND (SELECT count(*) FROM waitlist) < 10000 \
ON CONFLICT DO NOTHING", ON CONFLICT DO NOTHING",
) )
.bind(&email) .bind(&email)
.bind(&locale) .bind(&locale)
.execute(&state.db) .bind(db::token_hash(&token))
.await?; .execute(&mut *tx)
.await?
.rows_affected()
== 1;
// A confirmation, once, unless the address asked for no more mail from us.
if added && !opted_out(&mut tx, &email).await? {
let (_, unsubscribe_url, unsubscribe_post_url) = links(&state, &token);
let payload = json!({
"url": state.config.public_base_url,
"unsubscribe_url": unsubscribe_url,
"unsubscribe_post_url": unsubscribe_post_url,
});
queue_email_to(&mut tx, None, &email, "waitlist_joined", &locale, payload).await?;
state.login_limiter.failed(&key);
}
tx.commit().await?;
Ok((StatusCode::ACCEPTED, Json(json!({ "ok": true })))) Ok((StatusCode::ACCEPTED, Json(json!({ "ok": true }))))
} }
+1
View File
@@ -162,6 +162,7 @@ async fn public_config(State(state): St) -> Json<Value> {
"locales": c.supported_locales, "locales": c.supported_locales,
"password_login": c.password_login, "password_login": c.password_login,
"mock_payments": c.mock_payments, "mock_payments": c.mock_payments,
"user_invites": c.user_invites,
"signup_mode": c.signup_mode.as_str(), "signup_mode": c.signup_mode.as_str(),
"password_min_length": crate::auth::MIN_PASSWORD_LEN, "password_min_length": crate::auth::MIN_PASSWORD_LEN,
})) }))
@@ -260,6 +260,9 @@ pub async fn create_invite(
auth: AuthUser, auth: AuthUser,
WithRejection(Json(req), _): Body<CreateInvite>, WithRejection(Json(req), _): Body<CreateInvite>,
) -> ApiResult<(StatusCode, Json<Value>)> { ) -> ApiResult<(StatusCode, Json<Value>)> {
if !state.config.user_invites && !auth.user.has_role(db::Role::Admin) {
return Err(ApiError::conflict("invites_disabled", "A meghívás hamarosan indul."));
}
let chart = chart_or_primary(&state.db, req.chart_id, auth.id()).await?; let chart = chart_or_primary(&state.db, req.chart_id, auth.id()).await?;
// No links: the message may go out in an e-mail from our domain. // No links: the message may go out in an e-mail from our domain.
let message = super::invitations::clean_message(req.message)?; let message = super::invitations::clean_message(req.message)?;
+81
View File
@@ -2056,3 +2056,84 @@ async fn an_invitation_brings_its_package_and_codes_fill_up(pool: PgPool) {
(Some(2), Some(1), Some(5)) (Some(2), Some(1), Some(5))
); );
} }
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn the_waitlist_confirms_and_can_be_left(pool: PgPool) {
let app = TestApp::with_config(pool.clone(), |c| c.signup_mode = crate::config::SignupMode::Invite).await;
let admin = app.register("admin@example.com", "Admin").await;
let from = |ip: &'static str| [("x-forwarded-for", ip)];
// one confirmation per address, even when sent again
for _ in 0..2 {
let r = app
.call_with(
"POST",
"/v1/public/waitlist",
None,
Some(json!({"email": "Wait@Example.com"})),
&from("198.51.100.7"),
)
.await;
assert_eq!(r.status, StatusCode::ACCEPTED);
}
let mails: Vec<(Value,)> = sqlx::query_as(
"SELECT payload FROM email_outbox WHERE to_email = 'wait@example.com' AND template = 'waitlist_joined'",
)
.fetch_all(&pool)
.await
.unwrap();
assert_eq!(mails.len(), 1);
let leave = mails[0].0["unsubscribe_post_url"].as_str().unwrap().to_string();
let token = leave.rsplit("token=").next().unwrap().to_string();
// leaving: off the list, and no invitation can be sent there any more
let r = app.call("POST", &format!("/v1/public/invitations/unsubscribe?token={token}"), None, None).await;
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
assert!(app.get("/v1/admin/invitations", Some(&admin)).await.body["waitlist"].as_array().unwrap().is_empty());
let r = app.post("/v1/admin/invitations", Some(&admin), json!({"emails": ["wait@example.com"]})).await;
assert_eq!(r.body["results"][0]["status"], "opted_out");
// and signing up again sends nothing
app.call_with(
"POST",
"/v1/public/waitlist",
None,
Some(json!({"email": "wait@example.com"})),
&from("198.51.100.8"),
)
.await;
let count: i64 = sqlx::query_scalar("SELECT count(*) FROM email_outbox WHERE to_email = 'wait@example.com'")
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(count, 1);
// one address cannot flood the form
let mut last = StatusCode::OK;
for i in 0..12 {
let r = app
.call_with(
"POST",
"/v1/public/waitlist",
None,
Some(json!({"email": format!("w{i}@example.com")})),
&from("203.0.113.9"),
)
.await;
last = r.status;
}
assert_eq!(last, StatusCode::TOO_MANY_REQUESTS);
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn user_invitations_wait_for_the_launch(pool: PgPool) {
let app = TestApp::with_config(pool, |c| c.user_invites = false).await;
assert_eq!(app.get("/v1/config", None).await.body["user_invites"], false);
let anna = app.register("anna@example.com", "Anna").await;
app.chart(&anna, "Saját", true, "1990-03-15").await;
let r = app.post("/v1/invites", Some(&anna), json!({"label": "Béla"})).await;
assert_eq!((r.status, r.body["error"]["code"].as_str()), (StatusCode::CONFLICT, Some("invites_disabled")));
// admins may, to try it
let admin = app.register("admin@example.com", "Admin").await;
app.chart(&admin, "Saját", true, "1980-01-01").await;
assert_eq!(app.post("/v1/invites", Some(&admin), json!({})).await.status, StatusCode::CREATED);
}
@@ -403,13 +403,15 @@ function InvitationRow({ invitation: i, onChange }: { invitation: AdminInvitatio
function WaitlistTable({ waitlist, onChange }: { waitlist: WaitlistEntry[]; onChange: () => Promise<void> }) { function WaitlistTable({ waitlist, onChange }: { waitlist: WaitlistEntry[]; onChange: () => Promise<void> }) {
const [busy, setBusy] = useState<string | null>(null); const [busy, setBusy] = useState<string | null>(null);
const [note, setNote] = useState<string | null>(null); const [note, setNote] = useState<string | null>(null);
const [pkg, setPkg] = useState("");
const packages = usePackages();
async function invite(w: WaitlistEntry) { async function invite(w: WaitlistEntry) {
setBusy(w.email); setBusy(w.email);
setNote(null); setNote(null);
try { try {
const res = await api<{ results: InvitationResult[] }>("/admin/invitations", { const res = await api<{ results: InvitationResult[] }>("/admin/invitations", {
body: { emails: [w.email], locale: w.locale }, body: { emails: [w.email], locale: w.locale, package: pkg || null },
}); });
const r = res.results[0]; const r = res.results[0];
if (r && r.status !== "invited") setNote(`${r.email}: ${RESULT[r.status]}`); if (r && r.status !== "invited") setNote(`${r.email}: ${RESULT[r.status]}`);
@@ -440,6 +442,20 @@ function WaitlistTable({ waitlist, onChange }: { waitlist: WaitlistEntry[]; onCh
Várólista Várólista
</h2> </h2>
<p className="hint">Akik meghívó nélkül próbáltak belépni, és kérték, hogy szóljunk nekik.</p> <p className="hint">Akik meghívó nélkül próbáltak belépni, és kérték, hogy szóljunk nekik.</p>
{waitlist.some((w) => w.invitation === null) && (
<div className="field" style={{ maxWidth: 320 }}>
<label htmlFor="waitlist-package">Ajándék csomag a meghívottaknak</label>
<select id="waitlist-package" className="inp" value={pkg} onChange={(e) => setPkg(e.target.value)}>
<option value="">nincs</option>
{(packages ?? []).map((p) => (
<option key={p.id} value={p.id}>
{p.name}
</option>
))}
</select>
<span className="hint">A „Meghívás” gomb ezzel a csomaggal küldi a meghívót; a regisztrációkor magától jóváíródik.</span>
</div>
)}
{note && ( {note && (
<p className="msg msg-error" role="alert"> <p className="msg msg-error" role="alert">
{note} {note}
+5
View File
@@ -909,3 +909,8 @@ a.pair-row:hover strong { color: var(--gold); }
.lp-wheel .w-aspect { stroke-dashoffset: 0; } .lp-wheel .w-aspect { stroke-dashoffset: 0; }
.lp-wheel .w-aspect.w-asp-sextile { opacity: 1; } .lp-wheel .w-aspect.w-asp-sextile { opacity: 1; }
} }
.mode-option:disabled { cursor: not-allowed; opacity: 0.75; }
.mode-option:disabled:hover { border-color: var(--line-2); }
.mode-soon { margin-left: 8px; vertical-align: middle; font-family: var(--font-body); font-size: 11px; }
.invite-soon .btn:disabled { cursor: not-allowed; }
@@ -20,7 +20,7 @@ export function Unsubscribe({ token }: { token: string | null }) {
if (state === "done") { if (state === "done") {
return ( return (
<p className="msg msg-ok" role="status"> <p className="msg msg-ok" role="status">
Leiratkoztál: erre a címre nem küldünk több meghívót. Leiratkoztál: erre a címre nem küldünk több meghívót, és levettük a várólistáról.
</p> </p>
); );
} }
@@ -40,7 +40,8 @@ export function Unsubscribe({ token }: { token: string | null }) {
return ( return (
<div className="card field" style={{ gap: 12 }}> <div className="card field" style={{ gap: 12 }}>
<p style={{ margin: 0 }}> <p style={{ margin: 0 }}>
Ha leiratkozol, erre az e-mail-címre többé nem küldünk meghívót, és a mostani meghívód is érvényét veszti. 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.
</p> </p>
<div> <div>
<button type="button" className="btn btn-primary" onClick={confirm} disabled={state === "busy"}> <button type="button" className="btn btn-primary" onClick={confirm} disabled={state === "busy"}>
@@ -12,7 +12,7 @@ export default async function UnsubscribePage({ searchParams }: { searchParams:
<main className="page" style={{ maxWidth: 560 }}> <main className="page" style={{ maxWidth: 560 }}>
<div className="page-head"> <div className="page-head">
<h1>Leiratkozás</h1> <h1>Leiratkozás</h1>
<p className="muted">Nem kérsz több meghívót a Sorsfonalakra.</p> <p className="muted">Nem kérsz több levelet és meghívót a Sorsfonalakról.</p>
</div> </div>
<Unsubscribe token={token ?? null} /> <Unsubscribe token={token ?? null} />
</main> </main>
+39 -14
View File
@@ -23,6 +23,7 @@ export default async function PersonsPage() {
const isAdmin = me.user.roles.includes("admin"); const isAdmin = me.user.roles.includes("admin");
const slots = me.persons; const slots = me.persons;
const full = slots.left === 0; const full = slots.left === 0;
const invitesOpen = (config?.user_invites ?? false) || isAdmin;
const now = Date.now(); const now = Date.now();
return ( return (
@@ -47,22 +48,46 @@ export default async function PersonsPage() {
</ChartCard> </ChartCard>
))} ))}
<Link href="/szemelyek/uj" className="chart-card chart-card-new"> {(!full || invitesOpen) && (
<span className="chart-card-plus" aria-hidden="true"> <Link href="/szemelyek/uj" className="chart-card chart-card-new">
+ <span className="chart-card-plus" aria-hidden="true">
</span> +
<strong className="chart-card-name">Új személy</strong> </span>
<span className="muted"> <strong className="chart-card-name">Új személy</strong>
{full <span className="muted">
? "Meghívással bármikor" {!invitesOpen
: slots.unlimited ? slots.unlimited
? "Adatokkal vagy meghívással" ? "Korlátlan számú személy"
: `Még ${slots.left} személyt vehetsz fel, vagy hívd meg`} : `Még ${slots.left} személyt vehetsz fel`
</span> : full
</Link> ? "Meghívással bármikor"
: slots.unlimited
? "Adatokkal vagy meghívással"
: `Még ${slots.left} személyt vehetsz fel, vagy hívd meg`}
</span>
</Link>
)}
</div> </div>
<PendingInvites /> {invitesOpen ? (
<PendingInvites />
) : (
<section className="card invite-soon" aria-labelledby="invite-soon-title">
<div className="card-head">
<h2 id="invite-soon-title">Hívd meg, akit szeretsz</h2>
<span className="badge">Hamarosan</span>
</div>
<p className="muted">
Hamarosan te is meghívhatod a barátaidat, a családodat vagy a párodat: ők megadják a saját születési adataikat,
ingyen megkapják a képletüket, és együtt megnézitek, mennyire illetek össze.
</p>
<div>
<button type="button" className="btn" disabled>
Meghívó küldése
</button>
</div>
</section>
)}
{!slots.unlimited && ( {!slots.unlimited && (
<section className="card" aria-labelledby="slots-title"> <section className="card" aria-labelledby="slots-title">
@@ -14,16 +14,19 @@ import { NewPerson } from "./NewPerson";
export function NewPersonChooser({ export function NewPersonChooser({
canAdd, canAdd,
hasOwnChart, hasOwnChart,
invitesOpen,
full, full,
}: { }: {
/** A slot is free for typed-in data. */ /** A slot is free for typed-in data. */
canAdd: boolean; canAdd: boolean;
/** Inviting is on (until the launch it is shown, but off). */
invitesOpen: boolean;
/** Inviting compares with the user's own chart. */ /** Inviting compares with the user's own chart. */
hasOwnChart: boolean; hasOwnChart: boolean;
/** Shown instead of the form when no slot is left. */ /** Shown instead of the form when no slot is left. */
full: React.ReactNode; full: React.ReactNode;
}) { }) {
const [mode, setMode] = useState<"data" | "invite">(canAdd ? "data" : "invite"); const [mode, setMode] = useState<"data" | "invite">(canAdd || !invitesOpen ? "data" : "invite");
return ( return (
<div className="field" style={{ gap: 18 }}> <div className="field" style={{ gap: 18 }}>
<div className="mode-switch" role="tablist" aria-label="Hogyan veszed fel?"> <div className="mode-switch" role="tablist" aria-label="Hogyan veszed fel?">
@@ -41,11 +44,19 @@ export function NewPersonChooser({
type="button" type="button"
role="tab" role="tab"
aria-selected={mode === "invite"} aria-selected={mode === "invite"}
aria-disabled={!invitesOpen}
disabled={!invitesOpen}
className="mode-option" className="mode-option"
onClick={() => setMode("invite")} onClick={() => setMode("invite")}
> >
<strong>Meghívom</strong> <strong>
<span>Ő adja meg a saját adatait, és megnézitek, mennyire illetek össze. Ingyenes, nem kell hozzá hely.</span> Meghívom {!invitesOpen && <span className="badge mode-soon">Hamarosan</span>}
</strong>
<span>
{invitesOpen
? "Ő adja meg a saját adatait, és megnézitek, mennyire illetek össze. Ingyenes, nem kell hozzá hely."
: "Hamarosan meghívhatod azokat, akiket szeretsz: ők adják meg a saját adataikat, és együtt nézitek meg, mennyire illetek össze."}
</span>
</button> </button>
</div> </div>
{mode === "data" ? ( {mode === "data" ? (
@@ -27,6 +27,7 @@ export default async function NewPersonPage() {
<NewPersonChooser <NewPersonChooser
canAdd={slots.left !== 0} canAdd={slots.left !== 0}
hasOwnChart={me.primary_chart_id !== null} hasOwnChart={me.primary_chart_id !== null}
invitesOpen={(config?.user_invites ?? false) || me.user.roles.includes("admin")}
full={ full={
<> <>
<p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot, vagy hívd meg.</p> <p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot, vagy hívd meg.</p>
+2
View File
@@ -92,6 +92,8 @@ export interface PublicConfig {
mock_payments: boolean; mock_payments: boolean;
/** "invite": new accounts need an invitation. */ /** "invite": new accounts need an invitation. */
signup_mode: "invite" | "open"; signup_mode: "invite" | "open";
/** Users may invite others (off until the launch; admins always may). */
user_invites: boolean;
} }
export interface Position { export interface Position {