Error log: pages and deletion; no waitlist in the interface
- The error log pages (50 per page) instead of loading more and more; an
entry can be deleted, or every entry the filter matches at once
(DELETE /v1/admin/errors/{id}, DELETE /v1/admin/errors?source=&outcome=).
- The waitlist form (home page, login pages) and the admin waitlist table are
gone; the stored addresses and the backend routes are left as they are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
//! Admin: the error log of the analyses, answers and prompt test runs (every
|
//! Admin: the error log of the analyses, answers and prompt test runs (every
|
||||||
//! failed attempt, written by the worker), newest first.
|
//! failed attempt, written by the worker), newest first. Entries can be
|
||||||
|
//! deleted one by one or all that match a filter.
|
||||||
|
|
||||||
use axum::Json;
|
use axum::Json;
|
||||||
use axum::extract::{Query, State};
|
use axum::extract::{Path, Query, State};
|
||||||
|
use axum::http::StatusCode;
|
||||||
use axum_extra::extract::WithRejection;
|
use axum_extra::extract::WithRejection;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::{Value, json};
|
use serde_json::{Value, json};
|
||||||
@@ -71,3 +73,41 @@ pub async fn list(
|
|||||||
.collect();
|
.collect();
|
||||||
Ok(Json(json!({ "errors": errors, "total": total, "last_day": last_day, "limit": limit, "offset": offset })))
|
Ok(Json(json!({ "errors": errors, "total": total, "last_day": last_day, "limit": limit, "offset": offset })))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct DeleteQuery {
|
||||||
|
source: Option<String>,
|
||||||
|
outcome: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deletes every entry matching the filter (none given: all of them).
|
||||||
|
pub async fn delete_matching(
|
||||||
|
State(state): St,
|
||||||
|
AdminUser(admin): AdminUser,
|
||||||
|
WithRejection(Query(query), _): WithRejection<Query<DeleteQuery>, ApiError>,
|
||||||
|
) -> ApiResult<Json<Value>> {
|
||||||
|
let deleted = sqlx::query(
|
||||||
|
"DELETE FROM generation_errors WHERE ($1::text IS NULL OR source = $1) AND ($2::text IS NULL OR outcome = $2)",
|
||||||
|
)
|
||||||
|
.bind(&query.source)
|
||||||
|
.bind(&query.outcome)
|
||||||
|
.execute(&state.db)
|
||||||
|
.await?
|
||||||
|
.rows_affected();
|
||||||
|
tracing::info!(admin = %admin.id(), deleted, "error log entries deleted");
|
||||||
|
Ok(Json(json!({ "deleted": deleted })))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deletes one entry.
|
||||||
|
pub async fn delete_one(
|
||||||
|
State(state): St,
|
||||||
|
_admin: AdminUser,
|
||||||
|
WithRejection(Path(id), _): WithRejection<Path<i64>, ApiError>,
|
||||||
|
) -> ApiResult<StatusCode> {
|
||||||
|
let result = sqlx::query("DELETE FROM generation_errors WHERE id = $1").bind(id).execute(&state.db).await?;
|
||||||
|
if result.rows_affected() == 0 {
|
||||||
|
return Err(ApiError::NotFound("error"));
|
||||||
|
}
|
||||||
|
Ok(StatusCode::NO_CONTENT)
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ pub fn router(state: Arc<AppState>) -> Router {
|
|||||||
.route("/v1/admin/prompts/{kind}/{language}", axum::routing::put(prompts::save))
|
.route("/v1/admin/prompts/{kind}/{language}", axum::routing::put(prompts::save))
|
||||||
.route("/v1/admin/prompts/{kind}/{language}/preview", post(prompts::start_preview))
|
.route("/v1/admin/prompts/{kind}/{language}/preview", post(prompts::start_preview))
|
||||||
.route("/v1/admin/previews/{id}", get(prompts::get_preview))
|
.route("/v1/admin/previews/{id}", get(prompts::get_preview))
|
||||||
.route("/v1/admin/errors", get(errors::list))
|
.route("/v1/admin/errors", get(errors::list).delete(errors::delete_matching))
|
||||||
|
.route("/v1/admin/errors/{id}", axum::routing::delete(errors::delete_one))
|
||||||
.route("/v1/admin/jobs", get(jobs::list))
|
.route("/v1/admin/jobs", get(jobs::list))
|
||||||
.route("/v1/admin/jobs/restart", post(jobs::restart))
|
.route("/v1/admin/jobs/restart", post(jobs::restart))
|
||||||
.route("/v1/admin/models", get(models::list))
|
.route("/v1/admin/models", get(models::list))
|
||||||
|
|||||||
@@ -2214,6 +2214,19 @@ async fn admins_read_the_error_log(pool: PgPool) {
|
|||||||
let r = app.get("/v1/admin/errors?outcome=retry", Some(&admin)).await;
|
let r = app.get("/v1/admin/errors?outcome=retry", Some(&admin)).await;
|
||||||
assert_eq!(r.body["errors"].as_array().unwrap().len(), 1);
|
assert_eq!(r.body["errors"].as_array().unwrap().len(), 1);
|
||||||
assert_eq!(app.get("/v1/admin/errors?source=question", Some(&admin)).await.body["total"], 0);
|
assert_eq!(app.get("/v1/admin/errors?source=question", Some(&admin)).await.body["total"], 0);
|
||||||
|
// deleted one by one, or all that match the filter
|
||||||
|
let retry_id = r.body["errors"][0]["id"].as_i64().unwrap();
|
||||||
|
let r = app.call("DELETE", &format!("/v1/admin/errors/{retry_id}"), Some(&anna), None).await;
|
||||||
|
assert_eq!(r.status, StatusCode::FORBIDDEN);
|
||||||
|
let r = app.call("DELETE", &format!("/v1/admin/errors/{retry_id}"), Some(&admin), None).await;
|
||||||
|
assert_eq!(r.status, StatusCode::NO_CONTENT);
|
||||||
|
let r = app.call("DELETE", &format!("/v1/admin/errors/{retry_id}"), Some(&admin), None).await;
|
||||||
|
assert_eq!(r.status, StatusCode::NOT_FOUND);
|
||||||
|
let r = app.call("DELETE", "/v1/admin/errors?outcome=retry", Some(&admin), None).await;
|
||||||
|
assert_eq!(r.body["deleted"], 0);
|
||||||
|
let r = app.call("DELETE", "/v1/admin/errors?source=analysis", Some(&admin), None).await;
|
||||||
|
assert_eq!((r.status, &r.body["deleted"]), (StatusCode::OK, &json!(1)), "{}", r.body);
|
||||||
|
assert_eq!(app.get("/v1/admin/errors", Some(&admin)).await.body["total"], 0);
|
||||||
// users see the attempts of their analysis (the page says it is tried again)
|
// users see the attempts of their analysis (the page says it is tried again)
|
||||||
let r = app.get(&format!("/v1/analyses/{analysis}"), Some(&anna)).await;
|
let r = app.get(&format!("/v1/analyses/{analysis}"), Some(&anna)).await;
|
||||||
assert_eq!(r.body["attempts"], 0);
|
assert_eq!(r.body["attempts"], 0);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { ChartWheel } from "@/components/ChartWheel";
|
|||||||
import { Rich } from "@/components/Rich";
|
import { Rich } from "@/components/Rich";
|
||||||
import { TarotCard, TarotCardBack } from "@/components/tarot/TarotCard";
|
import { TarotCard, TarotCardBack } from "@/components/tarot/TarotCard";
|
||||||
import { Logo, PublicHeader } from "@/components/SiteHeader";
|
import { Logo, PublicHeader } from "@/components/SiteHeader";
|
||||||
import { Waitlist } from "@/components/Waitlist";
|
|
||||||
import example from "@/content/pelda.json";
|
import example from "@/content/pelda.json";
|
||||||
import { tarotCard } from "@/lib/tarot";
|
import { tarotCard } from "@/lib/tarot";
|
||||||
import type { AnalysisContent, ChartResult } from "@/lib/types";
|
import type { AnalysisContent, ChartResult } from "@/lib/types";
|
||||||
@@ -84,8 +83,7 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) {
|
|||||||
<p className="hint lp-rise lp-r4">
|
<p className="hint lp-rise lp-r4">
|
||||||
{inviteOnly ? (
|
{inviteOnly ? (
|
||||||
<>
|
<>
|
||||||
Az oldal egyelőre meghívásos: meghívóval, Google-fiókkal lépsz be. Ha még nincs meghívód,{" "}
|
Az oldal egyelőre meghívásos: meghívóval, Google-fiókkal lépsz be.
|
||||||
<a href="#varolista">iratkozz fel a várólistára</a>.
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
"A képlet és a rövid összefoglaló ingyenes. Google-fiókkal lépsz be."
|
"A képlet és a rövid összefoglaló ingyenes. Google-fiókkal lépsz be."
|
||||||
@@ -458,7 +456,7 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="varolista" className="lp-band lp-final">
|
<section className="lp-band lp-final">
|
||||||
<div className="lp-wrap lp-final-inner">
|
<div className="lp-wrap lp-final-inner">
|
||||||
<svg aria-hidden="true" viewBox="0 0 120 120" className="lp-spin lp-emblem">
|
<svg aria-hidden="true" viewBox="0 0 120 120" className="lp-spin lp-emblem">
|
||||||
<circle cx="60" cy="60" r="54" className="lp-emblem-outer" />
|
<circle cx="60" cy="60" r="54" className="lp-emblem-outer" />
|
||||||
@@ -470,17 +468,12 @@ export function Landing({ inviteOnly }: { inviteOnly: boolean }) {
|
|||||||
<h2 className="lp-h2">Kíváncsi vagy, mit mutat a te képleted?</h2>
|
<h2 className="lp-h2">Kíváncsi vagy, mit mutat a te képleted?</h2>
|
||||||
<p className="lp-text">
|
<p className="lp-text">
|
||||||
{inviteOnly
|
{inviteOnly
|
||||||
? "Egyelőre meghívással lehet csatlakozni. Ha kaptál meghívót, lépj be a Google-fiókoddal. Ha még nem, írd fel magad, és szólunk."
|
? "Egyelőre meghívással lehet csatlakozni. Ha kaptál meghívót, lépj be a Google-fiókoddal."
|
||||||
: "Két perc, és ott a képleted a rövid összefoglalóval együtt."}
|
: "Két perc, és ott a képleted a rövid összefoglalóval együtt."}
|
||||||
</p>
|
</p>
|
||||||
<Link href="/belepes" className="btn btn-primary lp-btn lp-btn-big">
|
<Link href="/belepes" className="btn btn-primary lp-btn lp-btn-big">
|
||||||
{signIn}
|
{signIn}
|
||||||
</Link>
|
</Link>
|
||||||
{inviteOnly && (
|
|
||||||
<div className="lp-waitlist">
|
|
||||||
<Waitlist />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<p className="hint lp-disclaimer">
|
<p className="hint lp-disclaimer">
|
||||||
Az elemzéseket mesterséges intelligencia írja a pontosan kiszámolt képlet alapján. Tájékoztató jellegűek, nem
|
Az elemzéseket mesterséges intelligencia írja a pontosan kiszámolt képlet alapján. Tájékoztató jellegűek, nem
|
||||||
helyettesítenek szakmai tanácsot.
|
helyettesítenek szakmai tanácsot.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { api, errorText } from "@/lib/api";
|
|||||||
import { formatDate } from "@/lib/astro";
|
import { formatDate } from "@/lib/astro";
|
||||||
import type { GenerationError } from "@/lib/types";
|
import type { GenerationError } from "@/lib/types";
|
||||||
|
|
||||||
const PAGE = 100;
|
const PAGE = 50;
|
||||||
|
|
||||||
const SOURCES: Record<string, string> = { analysis: "Elemzés", question: "Kérdés-válasz", preview: "Prompt-próba" };
|
const SOURCES: Record<string, string> = { analysis: "Elemzés", question: "Kérdés-válasz", preview: "Prompt-próba" };
|
||||||
const KINDS: Record<string, string> = {
|
const KINDS: Record<string, string> = {
|
||||||
@@ -33,43 +33,82 @@ interface Page {
|
|||||||
export function ErrorLog() {
|
export function ErrorLog() {
|
||||||
const [source, setSource] = useState("");
|
const [source, setSource] = useState("");
|
||||||
const [outcome, setOutcome] = useState("");
|
const [outcome, setOutcome] = useState("");
|
||||||
|
const [page, setPage] = useState(0);
|
||||||
const [errors, setErrors] = useState<GenerationError[] | null>(null);
|
const [errors, setErrors] = useState<GenerationError[] | null>(null);
|
||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const [lastDay, setLastDay] = useState(0);
|
const [lastDay, setLastDay] = useState(0);
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const load = useCallback(
|
const filter = useCallback(() => {
|
||||||
async (offset: number) => {
|
const params = new URLSearchParams();
|
||||||
setBusy(true);
|
|
||||||
setError(null);
|
|
||||||
const params = new URLSearchParams({ limit: String(PAGE), offset: String(offset) });
|
|
||||||
if (source) params.set("source", source);
|
if (source) params.set("source", source);
|
||||||
if (outcome) params.set("outcome", outcome);
|
if (outcome) params.set("outcome", outcome);
|
||||||
|
return params;
|
||||||
|
}, [source, outcome]);
|
||||||
|
|
||||||
|
const load = useCallback(async () => {
|
||||||
|
setBusy(true);
|
||||||
|
setError(null);
|
||||||
|
const params = filter();
|
||||||
|
params.set("limit", String(PAGE));
|
||||||
|
params.set("offset", String(page * PAGE));
|
||||||
try {
|
try {
|
||||||
const page = await api<Page>(`/admin/errors?${params}`);
|
const res = await api<Page>(`/admin/errors?${params}`);
|
||||||
setErrors((all) => (offset === 0 ? page.errors : [...(all ?? []), ...page.errors]));
|
// The last page emptied by deleting: one page back.
|
||||||
setTotal(page.total);
|
if (res.errors.length === 0 && page > 0) return setPage(Math.max(0, Math.ceil(res.total / PAGE) - 1));
|
||||||
setLastDay(page.last_day);
|
setErrors(res.errors);
|
||||||
|
setTotal(res.total);
|
||||||
|
setLastDay(res.last_day);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(errorText(e));
|
setError(errorText(e));
|
||||||
} finally {
|
} finally {
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
},
|
}, [filter, page]);
|
||||||
[source, outcome],
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
load(0);
|
load();
|
||||||
}, [load]);
|
}, [load]);
|
||||||
|
|
||||||
|
async function removeOne(id: number) {
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
await api(`/admin/errors/${id}`, { method: "DELETE" });
|
||||||
|
await load();
|
||||||
|
} catch (e) {
|
||||||
|
setError(errorText(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeMatching() {
|
||||||
|
const what = source || outcome ? `a szűrésnek megfelelő ${total} bejegyzést` : `mind a ${total} bejegyzést`;
|
||||||
|
if (!window.confirm(`Biztosan törlöd ${what}? Nem vonható vissza.`)) return;
|
||||||
|
setBusy(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
await api(`/admin/errors?${filter()}`, { method: "DELETE" });
|
||||||
|
setPage(0);
|
||||||
|
await load();
|
||||||
|
} catch (e) {
|
||||||
|
setError(errorText(e));
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const pages = Math.max(1, Math.ceil(total / PAGE));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="card" style={{ gap: 12 }}>
|
<section className="card" style={{ gap: 12 }}>
|
||||||
<div className="row" style={{ gap: 12, flexWrap: "wrap", alignItems: "flex-end" }}>
|
<div className="row" style={{ gap: 12, flexWrap: "wrap", alignItems: "flex-end" }}>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label htmlFor="error-source">Mi</label>
|
<label htmlFor="error-source">Mi</label>
|
||||||
<select id="error-source" className="inp" value={source} onChange={(e) => setSource(e.target.value)}>
|
<select id="error-source" className="inp" value={source} onChange={(e) => {
|
||||||
|
setSource(e.target.value);
|
||||||
|
setPage(0);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<option value="">mind</option>
|
<option value="">mind</option>
|
||||||
{Object.entries(SOURCES).map(([v, l]) => (
|
{Object.entries(SOURCES).map(([v, l]) => (
|
||||||
<option key={v} value={v}>
|
<option key={v} value={v}>
|
||||||
@@ -80,7 +119,11 @@ export function ErrorLog() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label htmlFor="error-outcome">Következmény</label>
|
<label htmlFor="error-outcome">Következmény</label>
|
||||||
<select id="error-outcome" className="inp" value={outcome} onChange={(e) => setOutcome(e.target.value)}>
|
<select id="error-outcome" className="inp" value={outcome} onChange={(e) => {
|
||||||
|
setOutcome(e.target.value);
|
||||||
|
setPage(0);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<option value="">mind</option>
|
<option value="">mind</option>
|
||||||
{Object.entries(OUTCOMES).map(([v, o]) => (
|
{Object.entries(OUTCOMES).map(([v, o]) => (
|
||||||
<option key={v} value={v}>
|
<option key={v} value={v}>
|
||||||
@@ -92,9 +135,14 @@ export function ErrorLog() {
|
|||||||
<p className="hint" style={{ margin: 0 }}>
|
<p className="hint" style={{ margin: 0 }}>
|
||||||
{total} bejegyzés, ebből {lastDay} az elmúlt 24 órában
|
{total} bejegyzés, ebből {lastDay} az elmúlt 24 órában
|
||||||
</p>
|
</p>
|
||||||
<button type="button" className="btn btn-sm btn-ghost" onClick={() => load(0)} disabled={busy}>
|
<button type="button" className="btn btn-sm btn-ghost" onClick={load} disabled={busy}>
|
||||||
Frissítés
|
Frissítés
|
||||||
</button>
|
</button>
|
||||||
|
{total > 0 && (
|
||||||
|
<button type="button" className="btn btn-sm btn-danger" onClick={removeMatching} disabled={busy}>
|
||||||
|
{source || outcome ? `A szűrt ${total} törlése` : `Mind a ${total} törlése`}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{error && (
|
{error && (
|
||||||
<p className="msg msg-error" role="alert">
|
<p className="msg msg-error" role="alert">
|
||||||
@@ -116,6 +164,9 @@ export function ErrorLog() {
|
|||||||
<th>Kísérlet</th>
|
<th>Kísérlet</th>
|
||||||
<th>Következmény</th>
|
<th>Következmény</th>
|
||||||
<th>Hiba</th>
|
<th>Hiba</th>
|
||||||
|
<th>
|
||||||
|
<span className="sr-only">Törlés</span>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -140,16 +191,40 @@ export function ErrorLog() {
|
|||||||
<span className={`outcome tone-${OUTCOMES[e.outcome].tone}`}>{OUTCOMES[e.outcome].label}</span>
|
<span className={`outcome tone-${OUTCOMES[e.outcome].tone}`}>{OUTCOMES[e.outcome].label}</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="error-text">{e.error}</td>
|
<td className="error-text">{e.error}</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-ghost"
|
||||||
|
onClick={() => removeOne(e.id)}
|
||||||
|
aria-label="Bejegyzés törlése"
|
||||||
|
title="Bejegyzés törlése"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{errors && errors.length < total && (
|
{total > PAGE && (
|
||||||
<button type="button" className="btn btn-sm" onClick={() => load(errors.length)} disabled={busy}>
|
<nav className="pager" aria-label="Lapozás">
|
||||||
{busy ? "Betöltés…" : "Régebbiek"}
|
<button type="button" className="btn btn-sm" disabled={busy || page === 0} onClick={() => setPage(page - 1)}>
|
||||||
|
‹ Újabbak
|
||||||
</button>
|
</button>
|
||||||
|
<span className="num">
|
||||||
|
{page * PAGE + 1}–{Math.min(total, (page + 1) * PAGE)} / {total} · {page + 1}/{pages}. oldal
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm"
|
||||||
|
disabled={busy || page + 1 >= pages}
|
||||||
|
onClick={() => setPage(page + 1)}
|
||||||
|
>
|
||||||
|
Régebbiek ›
|
||||||
|
</button>
|
||||||
|
</nav>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
|
|||||||
import { usePackages } from "@/components/PackageCards";
|
import { usePackages } from "@/components/PackageCards";
|
||||||
import { api, errorText } from "@/lib/api";
|
import { api, errorText } from "@/lib/api";
|
||||||
import { formatDate } from "@/lib/astro";
|
import { formatDate } from "@/lib/astro";
|
||||||
import type { AdminInvitation, InvitationResult, WaitlistEntry } from "@/lib/types";
|
import type { AdminInvitation, InvitationResult } from "@/lib/types";
|
||||||
|
|
||||||
const MAX_MESSAGE = 300;
|
const MAX_MESSAGE = 300;
|
||||||
|
|
||||||
@@ -33,7 +33,6 @@ const RESULT: Record<InvitationResult["status"], string> = {
|
|||||||
|
|
||||||
interface ListData {
|
interface ListData {
|
||||||
invitations: AdminInvitation[];
|
invitations: AdminInvitation[];
|
||||||
waitlist: WaitlistEntry[];
|
|
||||||
signup_mode: "invite" | "open";
|
signup_mode: "invite" | "open";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +95,6 @@ export function AdminInvitations() {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{data && <InvitationList invitations={data.invitations} onChange={load} />}
|
{data && <InvitationList invitations={data.invitations} onChange={load} />}
|
||||||
{data && <WaitlistTable waitlist={data.waitlist} onChange={load} />}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -399,117 +397,3 @@ function InvitationRow({ invitation: i, onChange }: { invitation: AdminInvitatio
|
|||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function WaitlistTable({ waitlist, onChange }: { waitlist: WaitlistEntry[]; onChange: () => Promise<void> }) {
|
|
||||||
const [busy, setBusy] = useState<string | null>(null);
|
|
||||||
const [note, setNote] = useState<string | null>(null);
|
|
||||||
const [pkg, setPkg] = useState("");
|
|
||||||
const packages = usePackages();
|
|
||||||
|
|
||||||
async function invite(w: WaitlistEntry) {
|
|
||||||
setBusy(w.email);
|
|
||||||
setNote(null);
|
|
||||||
try {
|
|
||||||
const res = await api<{ results: InvitationResult[] }>("/admin/invitations", {
|
|
||||||
body: { emails: [w.email], locale: w.locale, package: pkg || null },
|
|
||||||
});
|
|
||||||
const r = res.results[0];
|
|
||||||
if (r && r.status !== "invited") setNote(`${r.email}: ${RESULT[r.status]}`);
|
|
||||||
await onChange();
|
|
||||||
} catch (e) {
|
|
||||||
setNote(errorText(e));
|
|
||||||
} finally {
|
|
||||||
setBusy(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function remove(w: WaitlistEntry) {
|
|
||||||
setBusy(w.email);
|
|
||||||
setNote(null);
|
|
||||||
try {
|
|
||||||
await api(`/admin/waitlist/${encodeURIComponent(w.email)}`, { method: "DELETE" });
|
|
||||||
await onChange();
|
|
||||||
} catch (e) {
|
|
||||||
setNote(errorText(e));
|
|
||||||
} finally {
|
|
||||||
setBusy(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className="card" aria-labelledby="waitlist-title">
|
|
||||||
<h2 id="waitlist-title" style={{ marginTop: 0 }}>
|
|
||||||
Várólista
|
|
||||||
</h2>
|
|
||||||
<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 && (
|
|
||||||
<p className="msg msg-error" role="alert">
|
|
||||||
{note}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
{waitlist.length === 0 ? (
|
|
||||||
<p className="muted">Üres.</p>
|
|
||||||
) : (
|
|
||||||
<div className="table-wrap">
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">Cím</th>
|
|
||||||
<th scope="col">Feliratkozott</th>
|
|
||||||
<th scope="col">Meghívó</th>
|
|
||||||
<th scope="col">
|
|
||||||
<span className="sr-only">Műveletek</span>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{waitlist.map((w) => (
|
|
||||||
<tr key={w.email}>
|
|
||||||
<td>{w.email}</td>
|
|
||||||
<td className="num">{formatDate(w.created_at)}</td>
|
|
||||||
<td>{w.invitation === "pending" ? "elküldve" : w.invitation === "accepted" ? "elfogadva" : "–"}</td>
|
|
||||||
<td>
|
|
||||||
<div className="row" style={{ gap: 4, flexWrap: "nowrap", justifyContent: "flex-end" }}>
|
|
||||||
{w.invitation === null && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm"
|
|
||||||
onClick={() => invite(w)}
|
|
||||||
disabled={busy !== null}
|
|
||||||
>
|
|
||||||
Meghívás
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm btn-ghost"
|
|
||||||
onClick={() => remove(w)}
|
|
||||||
disabled={busy !== null}
|
|
||||||
>
|
|
||||||
Törlés
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Script from "next/script";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { Waitlist } from "@/components/Waitlist";
|
|
||||||
import { ApiError, api, errorText } from "@/lib/api";
|
import { ApiError, api, errorText } from "@/lib/api";
|
||||||
|
|
||||||
/** The part of Sign in with Apple JS (appleid.auth.js) we use. */
|
/** The part of Sign in with Apple JS (appleid.auth.js) we use. */
|
||||||
@@ -136,7 +135,6 @@ export function AppleLogin({
|
|||||||
? "Ez a meghívó már nem érvényes, és ehhez az Apple-fiókhoz sem tartozik másik."
|
? "Ez a meghívó már nem érvényes, és ehhez az Apple-fiókhoz sem tartozik másik."
|
||||||
: "A Sorsfonalak jelenleg meghívásos, és ehhez az Apple-fiókhoz nem tartozik meghívó. Ha kaptál meghívót, nyisd meg a levélben kapott linket, vagy lépj be azzal a fiókkal, amelynek a címére a meghívó szólt."}
|
: "A Sorsfonalak jelenleg meghívásos, és ehhez az Apple-fiókhoz nem tartozik meghívó. Ha kaptál meghívót, nyisd meg a levélben kapott linket, vagy lépj be azzal a fiókkal, amelynek a címére a meghívó szólt."}
|
||||||
</p>
|
</p>
|
||||||
<Waitlist email={uninvited.endsWith("@privaterelay.appleid.com") ? "" : uninvited} />
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Script from "next/script";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
import { Waitlist } from "@/components/Waitlist";
|
|
||||||
import { ApiError, api, errorText } from "@/lib/api";
|
import { ApiError, api, errorText } from "@/lib/api";
|
||||||
|
|
||||||
/** Google's "G" mark (branding guidelines: unmodified, on the left of the label). */
|
/** Google's "G" mark (branding guidelines: unmodified, on the left of the label). */
|
||||||
@@ -130,7 +129,6 @@ export function GoogleLogin({
|
|||||||
? "Ez a meghívó már nem érvényes, és ehhez a Google-fiókhoz sem tartozik másik."
|
? "Ez a meghívó már nem érvényes, és ehhez a Google-fiókhoz sem tartozik másik."
|
||||||
: `A Sorsfonalak jelenleg meghívásos, és ${uninvited ? `a(z) ${uninvited} címhez` : "ehhez a fiókhoz"} nem tartozik meghívó. Ha kaptál meghívót egy másik címre, lépj be azzal a Google-fiókkal, vagy nyisd meg a levélben kapott linket.`}
|
: `A Sorsfonalak jelenleg meghívásos, és ${uninvited ? `a(z) ${uninvited} címhez` : "ehhez a fiókhoz"} nem tartozik meghívó. Ha kaptál meghívót egy másik címre, lépj be azzal a Google-fiókkal, vagy nyisd meg a levélben kapott linket.`}
|
||||||
</p>
|
</p>
|
||||||
<Waitlist email={uninvited} />
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
import { Waitlist } from "@/components/Waitlist";
|
|
||||||
import { ApiError, api, errorText } from "@/lib/api";
|
import { ApiError, api, errorText } from "@/lib/api";
|
||||||
|
|
||||||
type Mode = "login" | "register" | "forgot";
|
type Mode = "login" | "register" | "forgot";
|
||||||
@@ -178,7 +177,6 @@ export function PasswordLogin({
|
|||||||
? "Ez a meghívó már nem érvényes, és ehhez a címhez sem tartozik másik."
|
? "Ez a meghívó már nem érvényes, és ehhez a címhez sem tartozik másik."
|
||||||
: "A Sorsfonalak jelenleg meghívásos, és ehhez az e-mail-címhez nem tartozik meghívó. Ha kaptál meghívót, nyisd meg a levélben kapott linket."}
|
: "A Sorsfonalak jelenleg meghívásos, és ehhez az e-mail-címhez nem tartozik meghívó. Ha kaptál meghívót, nyisd meg a levélben kapott linket."}
|
||||||
</p>
|
</p>
|
||||||
<Waitlist email={email} />
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<p className="hint pw-switch" style={{ margin: 0 }}>
|
<p className="hint pw-switch" style={{ margin: 0 }}>
|
||||||
|
|||||||
@@ -982,7 +982,6 @@ a.pair-row:hover strong { color: var(--gold); }
|
|||||||
.lp-final-inner { max-width: 820px; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
|
.lp-final-inner { max-width: 820px; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
|
||||||
.lp-emblem { width: 88px; height: 88px; }
|
.lp-emblem { width: 88px; height: 88px; }
|
||||||
.lp-emblem-outer { fill: none; stroke: var(--gold); stroke-opacity: 0.5; stroke-width: 1; }
|
.lp-emblem-outer { fill: none; stroke: var(--gold); stroke-opacity: 0.5; stroke-width: 1; }
|
||||||
.lp-waitlist { width: 100%; max-width: 520px; text-align: left; }
|
|
||||||
.lp-disclaimer { max-width: 560px; }
|
.lp-disclaimer { max-width: 560px; }
|
||||||
.lp-footer { border-top: 1px solid var(--line); padding: 28px 0; }
|
.lp-footer { border-top: 1px solid var(--line); padding: 28px 0; }
|
||||||
.lp-footer-inner { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
|
.lp-footer-inner { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
import { api, errorText } from "@/lib/api";
|
|
||||||
|
|
||||||
/** "Tell me when it opens": for visitors without an invitation. */
|
|
||||||
export function Waitlist({ email: initial = "" }: { email?: string }) {
|
|
||||||
const [email, setEmail] = useState(initial);
|
|
||||||
const [busy, setBusy] = useState(false);
|
|
||||||
const [done, setDone] = useState(false);
|
|
||||||
const [error, setError] = useState<string | null>(null);
|
|
||||||
|
|
||||||
async function submit(e: React.FormEvent) {
|
|
||||||
e.preventDefault();
|
|
||||||
setBusy(true);
|
|
||||||
setError(null);
|
|
||||||
try {
|
|
||||||
await api("/public/waitlist", { body: { email, locale: "hu" } });
|
|
||||||
setDone(true);
|
|
||||||
} catch (err) {
|
|
||||||
setError(errorText(err));
|
|
||||||
} finally {
|
|
||||||
setBusy(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
return (
|
|
||||||
<p className="msg msg-ok" role="status">
|
|
||||||
Felírtunk. Ha megnyílik az oldal, vagy meghívót küldünk, ide írunk: <strong>{email}</strong>
|
|
||||||
</p>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<form onSubmit={submit} className="card waitlist">
|
|
||||||
<p style={{ margin: 0 }}>
|
|
||||||
<strong>Szólunk, ha megnyílik.</strong>{" "}
|
|
||||||
<span className="muted">Add meg az e-mail-címed, és felírunk a várólistára.</span>
|
|
||||||
</p>
|
|
||||||
<div className="row" style={{ gap: 8, flexWrap: "wrap" }}>
|
|
||||||
<label htmlFor="waitlist-email" className="sr-only">
|
|
||||||
E-mail-cím
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
id="waitlist-email"
|
|
||||||
className="inp"
|
|
||||||
type="email"
|
|
||||||
required
|
|
||||||
autoComplete="email"
|
|
||||||
value={email}
|
|
||||||
onChange={(e) => setEmail(e.target.value)}
|
|
||||||
placeholder="nev@pelda.hu"
|
|
||||||
style={{ flex: "1 1 220px" }}
|
|
||||||
/>
|
|
||||||
<button type="submit" className="btn" disabled={busy}>
|
|
||||||
{busy ? "Küldés…" : "Feliratkozom"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
{error && (
|
|
||||||
<p className="msg msg-error" role="alert">
|
|
||||||
{error}
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -511,14 +511,6 @@ export interface AdminInvitation {
|
|||||||
package: { id: string; name: string | null; code: string | null; redeemed_at: string | null } | null;
|
package: { id: string; name: string | null; code: string | null; redeemed_at: string | null } | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WaitlistEntry {
|
|
||||||
email: string;
|
|
||||||
locale: string;
|
|
||||||
created_at: string;
|
|
||||||
/** The address's latest invitation, if any. */
|
|
||||||
invitation: "pending" | "accepted" | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InvitationResult {
|
export interface InvitationResult {
|
||||||
email: string;
|
email: string;
|
||||||
status: "invited" | "invalid" | "already_user" | "already_invited" | "opted_out";
|
status: "invited" | "invalid" | "already_user" | "already_invited" | "opted_out";
|
||||||
|
|||||||
Reference in New Issue
Block a user