Detailed analysis button, loading wheel, birth data change limits
Backend: - own birth data: three corrections within an hour of the first save, then one change per 24 hours (birth_data_changes); 429 birth_data_change_limit with the user-facing message; /v1/me birth_change shows the notice; admins are not limited - admins get detailed analyses free (no unit spent) - POST /v1/payments/mock (MOCK_PAYMENTS): stand-in payment that adds a unit, until Stripe is connected; on in the compose files for now Frontend: - detailed analysis offer: admin starts it free, users with units confirm, others go through the (stand-in) payment step - turning wheel with elapsed time while the summary or the analysis is being written - no "adatok javítása" on the chart page (only in the profile), limit notice there; wheel hover highlighting removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
-- Every time a user's own (primary) birth data is set or changed. The
|
||||||
|
-- backend limits changes with it: after the first save, three corrections
|
||||||
|
-- within an hour, then one per 24 hours (admins are not limited).
|
||||||
|
|
||||||
|
CREATE TABLE birth_data_changes (
|
||||||
|
id uuid PRIMARY KEY,
|
||||||
|
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
||||||
|
chart_id uuid REFERENCES charts (id) ON DELETE SET NULL,
|
||||||
|
created_at timestamptz NOT NULL DEFAULT now()
|
||||||
|
);
|
||||||
|
CREATE INDEX birth_data_changes_user_idx ON birth_data_changes (user_id, created_at);
|
||||||
|
|
||||||
|
-- The current primary charts count as the first save.
|
||||||
|
INSERT INTO birth_data_changes (id, user_id, chart_id, created_at)
|
||||||
|
SELECT gen_random_uuid(), owner_id, id, created_at FROM charts WHERE is_primary;
|
||||||
@@ -85,6 +85,8 @@ services:
|
|||||||
ANALYSIS_MODEL: ${ANALYSIS_MODEL:-}
|
ANALYSIS_MODEL: ${ANALYSIS_MODEL:-}
|
||||||
SUMMARY_MODEL: ${SUMMARY_MODEL:-}
|
SUMMARY_MODEL: ${SUMMARY_MODEL:-}
|
||||||
PASSWORD_LOGIN: ${PASSWORD_LOGIN:-false}
|
PASSWORD_LOGIN: ${PASSWORD_LOGIN:-false}
|
||||||
|
# Stand-in payment (adds an analysis unit at once) until Stripe is connected.
|
||||||
|
MOCK_PAYMENTS: ${MOCK_PAYMENTS:-true}
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ services:
|
|||||||
SUMMARY_MODEL: ${SUMMARY_MODEL:-}
|
SUMMARY_MODEL: ${SUMMARY_MODEL:-}
|
||||||
# E-mail + password login; off by default (Google, Apple and Facebook only).
|
# E-mail + password login; off by default (Google, Apple and Facebook only).
|
||||||
PASSWORD_LOGIN: ${PASSWORD_LOGIN:-false}
|
PASSWORD_LOGIN: ${PASSWORD_LOGIN:-false}
|
||||||
|
# Stand-in payment (adds an analysis unit at once) until Stripe is connected.
|
||||||
|
MOCK_PAYMENTS: ${MOCK_PAYMENTS:-true}
|
||||||
depends_on:
|
depends_on:
|
||||||
postgres:
|
postgres:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Felhasználók, belépés, mentett születési képletek, szinasztriák és megh
|
|||||||
| `COOKIE_DOMAIN` | – | pl. `.sorsfonalak.hu`, ha a frontend és az API más aldomainen fut |
|
| `COOKIE_DOMAIN` | – | pl. `.sorsfonalak.hu`, ha a frontend és az API más aldomainen fut |
|
||||||
| `SESSION_TTL_DAYS` | `30` | a munkamenet élettartama |
|
| `SESSION_TTL_DAYS` | `30` | a munkamenet élettartama |
|
||||||
| `PASSWORD_LOGIN` | `false` | e-mail + jelszó regisztráció és belépés; élesben ki van kapcsolva (csak Google, Apple, Facebook), a jelszavas végpontok ilyenkor 403-at adnak |
|
| `PASSWORD_LOGIN` | `false` | e-mail + jelszó regisztráció és belépés; élesben ki van kapcsolva (csak Google, Apple, Facebook), a jelszavas végpontok ilyenkor 403-at adnak |
|
||||||
|
| `MOCK_PAYMENTS` | `false` | próbafizetés a Stripe bekötéséig: a `POST /v1/payments/mock` azonnal jóváír egy elemzési egységet (a compose-fájlokban egyelőre `true`) |
|
||||||
| `GOOGLE_CLIENT_IDS` | – | Google OAuth kliens-azonosító(k); üresen a Google-belépés ki van kapcsolva |
|
| `GOOGLE_CLIENT_IDS` | – | Google OAuth kliens-azonosító(k); üresen a Google-belépés ki van kapcsolva |
|
||||||
| `BOOTSTRAP_ADMIN_EMAILS` | – | ezek a címek regisztrációkor vagy belépéskor admin szerepet kapnak (így lesz meg az első admin) |
|
| `BOOTSTRAP_ADMIN_EMAILS` | – | ezek a címek regisztrációkor vagy belépéskor admin szerepet kapnak (így lesz meg az első admin) |
|
||||||
| `SUPPORTED_LOCALES` | `hu,en` | felület- és elemzésnyelvek; az első az alapértelmezett |
|
| `SUPPORTED_LOCALES` | `hu,en` | felület- és elemzésnyelvek; az első az alapértelmezett |
|
||||||
@@ -111,3 +112,8 @@ Hibák formátuma: `{"error": {"code", "message"}}`. A születési adatok hibái
|
|||||||
## Háttérmunkák
|
## Háttérmunkák
|
||||||
|
|
||||||
A [worker](../worker/README.md) kiküldi az e-maileket, megírja az elemzéseket (OpenRouter, strukturált JSON; hibánál visszaadja az egységet), és óránként takarít. Még hátravan az elemzés streamelése a frontend felé.
|
A [worker](../worker/README.md) kiküldi az e-maileket, megírja az elemzéseket (OpenRouter, strukturált JSON; hibánál visszaadja az egységet), és óránként takarít. Még hátravan az elemzés streamelése a frontend felé.
|
||||||
|
|
||||||
|
## Korlátok
|
||||||
|
|
||||||
|
- **Saját születési adatok módosítása:** az első mentés után egy órán belül még háromszor javíthatók, utána naponta egyszer (`birth_data_changes` tábla). A tiltott módosítás 429-et ad `birth_data_change_limit` kóddal, a felhasználónak szóló üzenettel („A rendszer csak napi egy módosítást engedélyez. …”). A `/v1/me` `birth_change` mezője mutatja, él-e a napi korlát. Más emberek képleteit ez nem érinti.
|
||||||
|
- **Admin:** nincs módosítási korlát, és a részletes elemzés ingyenes (nem fogy egység).
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
//! Limits on changing a user's own birth data.
|
||||||
|
//!
|
||||||
|
//! The first save is free. Within an hour of it the user may correct the data
|
||||||
|
//! three more times; after that, once per 24 hours. Admins are not limited.
|
||||||
|
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use sqlx::PgConnection;
|
||||||
|
use time::{Duration, OffsetDateTime};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::auth::AuthUser;
|
||||||
|
use crate::error::ApiError;
|
||||||
|
use crate::views::rfc3339;
|
||||||
|
use db::Role;
|
||||||
|
|
||||||
|
const GRACE_PERIOD: Duration = Duration::hours(1);
|
||||||
|
const GRACE_CHANGES: usize = 3;
|
||||||
|
const DAILY: Duration = Duration::hours(24);
|
||||||
|
|
||||||
|
pub const DAILY_NOTICE: &str = "A rendszer csak napi egy módosítást engedélyez.";
|
||||||
|
|
||||||
|
/// Where a user stands with changing their birth data.
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
pub struct Status {
|
||||||
|
/// The grace period is over (or used up): one change per day.
|
||||||
|
pub daily: bool,
|
||||||
|
/// When the next change is possible; `None`: now.
|
||||||
|
pub next_at: Option<OffsetDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The rule itself, over the times of the earlier saves (oldest first).
|
||||||
|
pub fn evaluate(saves: &[OffsetDateTime], now: OffsetDateTime) -> Status {
|
||||||
|
let (Some(&first), Some(&last)) = (saves.first(), saves.last()) else {
|
||||||
|
return Status { daily: false, next_at: None };
|
||||||
|
};
|
||||||
|
let corrections = saves.len() - 1;
|
||||||
|
if now - first < GRACE_PERIOD && corrections < GRACE_CHANGES {
|
||||||
|
return Status { daily: false, next_at: None };
|
||||||
|
}
|
||||||
|
let next = last + DAILY;
|
||||||
|
Status { daily: true, next_at: (next > now).then_some(next) }
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn saves(conn: &mut PgConnection, user_id: Uuid) -> Result<Vec<OffsetDateTime>, ApiError> {
|
||||||
|
let rows: Vec<(OffsetDateTime,)> =
|
||||||
|
sqlx::query_as("SELECT created_at FROM birth_data_changes WHERE user_id = $1 ORDER BY created_at")
|
||||||
|
.bind(user_id)
|
||||||
|
.fetch_all(conn)
|
||||||
|
.await?;
|
||||||
|
Ok(rows.into_iter().map(|(t,)| t).collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "23 óra 5 perc" / "40 perc" (rounded up to a minute).
|
||||||
|
fn wait_text(wait: Duration) -> String {
|
||||||
|
let minutes = (wait.whole_seconds() + 59) / 60;
|
||||||
|
let (h, m) = (minutes / 60, minutes % 60);
|
||||||
|
match (h, m) {
|
||||||
|
(0, m) => format!("{m} perc"),
|
||||||
|
(h, 0) => format!("{h} óra"),
|
||||||
|
(h, m) => format!("{h} óra {m} perc"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn limit_error(next_at: OffsetDateTime, now: OffsetDateTime) -> ApiError {
|
||||||
|
ApiError::Limited {
|
||||||
|
code: "birth_data_change_limit",
|
||||||
|
message: format!("{DAILY_NOTICE} Legközelebb {} múlva módosíthatod.", wait_text(next_at - now)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// For `/v1/me`: whether the daily limit applies and, if so, the notice to show.
|
||||||
|
pub async fn view(conn: &mut PgConnection, auth: &AuthUser) -> Result<Value, ApiError> {
|
||||||
|
if auth.user.has_role(Role::Admin) {
|
||||||
|
return Ok(json!({ "limited": false, "next_change_at": null, "notice": null }));
|
||||||
|
}
|
||||||
|
let now = OffsetDateTime::now_utc();
|
||||||
|
let status = evaluate(&saves(conn, auth.id()).await?, now);
|
||||||
|
let notice = match status.next_at {
|
||||||
|
Some(next) => Some(format!("{DAILY_NOTICE} Legközelebb {} múlva módosíthatod.", wait_text(next - now))),
|
||||||
|
None if status.daily => Some(DAILY_NOTICE.to_string()),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
Ok(json!({
|
||||||
|
"limited": status.daily,
|
||||||
|
"next_change_at": status.next_at.map(rfc3339),
|
||||||
|
"notice": notice,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Checks the limit and records the change, inside the transaction that
|
||||||
|
/// makes `chart_id` the user's own chart. Locks the user row, so parallel
|
||||||
|
/// saves are counted one after the other.
|
||||||
|
pub async fn record(tx: &mut PgConnection, auth: &AuthUser, chart_id: Uuid) -> Result<(), ApiError> {
|
||||||
|
sqlx::query("SELECT id FROM users WHERE id = $1 FOR UPDATE").bind(auth.id()).execute(&mut *tx).await?;
|
||||||
|
if !auth.user.has_role(Role::Admin) {
|
||||||
|
let now = OffsetDateTime::now_utc();
|
||||||
|
if let Some(next) = evaluate(&saves(tx, auth.id()).await?, now).next_at {
|
||||||
|
return Err(limit_error(next, now));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sqlx::query("INSERT INTO birth_data_changes (id, user_id, chart_id) VALUES ($1, $2, $3)")
|
||||||
|
.bind(Uuid::now_v7())
|
||||||
|
.bind(auth.id())
|
||||||
|
.bind(chart_id)
|
||||||
|
.execute(tx)
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn at(minutes: i64) -> OffsetDateTime {
|
||||||
|
OffsetDateTime::UNIX_EPOCH + Duration::minutes(minutes)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn first_save_is_free() {
|
||||||
|
assert_eq!(evaluate(&[], at(0)), Status { daily: false, next_at: None });
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn three_corrections_within_the_first_hour() {
|
||||||
|
let now = at(30);
|
||||||
|
assert_eq!(evaluate(&[at(0)], now).next_at, None);
|
||||||
|
assert_eq!(evaluate(&[at(0), at(5), at(10)], now).next_at, None);
|
||||||
|
// the third correction used up the grace period
|
||||||
|
let s = evaluate(&[at(0), at(5), at(10), at(20)], now);
|
||||||
|
assert!(s.daily);
|
||||||
|
assert_eq!(s.next_at, Some(at(20) + DAILY));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn after_the_first_hour_once_a_day() {
|
||||||
|
assert_eq!(evaluate(&[at(0)], at(61)), Status { daily: true, next_at: Some(at(24 * 60)) });
|
||||||
|
assert_eq!(evaluate(&[at(0)], at(24 * 60)), Status { daily: true, next_at: None });
|
||||||
|
assert_eq!(evaluate(&[at(0), at(24 * 60 + 5)], at(30 * 60)).next_at, Some(at(48 * 60 + 5)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn wait_is_written_in_hours_and_minutes() {
|
||||||
|
assert_eq!(wait_text(Duration::minutes(40)), "40 perc");
|
||||||
|
assert_eq!(wait_text(Duration::hours(3)), "3 óra");
|
||||||
|
assert_eq!(wait_text(Duration::seconds(23 * 3600 + 4 * 60 + 1)), "23 óra 5 perc");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,9 @@ pub struct Config {
|
|||||||
/// `PASSWORD_LOGIN` (default `false`): e-mail and password registration and
|
/// `PASSWORD_LOGIN` (default `false`): e-mail and password registration and
|
||||||
/// login. Off in production, where only Google, Apple and Facebook are offered.
|
/// login. Off in production, where only Google, Apple and Facebook are offered.
|
||||||
pub password_login: bool,
|
pub password_login: bool,
|
||||||
|
/// `MOCK_PAYMENTS` (default `false`): a stand-in payment that adds an
|
||||||
|
/// analysis unit at once, until Stripe is connected.
|
||||||
|
pub mock_payments: 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>,
|
||||||
@@ -87,6 +90,7 @@ impl Config {
|
|||||||
cookie_domain: var("COOKIE_DOMAIN"),
|
cookie_domain: var("COOKIE_DOMAIN"),
|
||||||
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)?,
|
||||||
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()),
|
||||||
@@ -115,6 +119,7 @@ impl Config {
|
|||||||
cookie_domain: None,
|
cookie_domain: None,
|
||||||
session_ttl_days: 30,
|
session_ttl_days: 30,
|
||||||
password_login: true,
|
password_login: true,
|
||||||
|
mock_payments: 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()],
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ pub enum ApiError {
|
|||||||
InsufficientCredits { unit: &'static str, balance: i64 },
|
InsufficientCredits { unit: &'static str, balance: i64 },
|
||||||
#[error("too many attempts; try again later")]
|
#[error("too many attempts; try again later")]
|
||||||
TooManyRequests,
|
TooManyRequests,
|
||||||
|
/// A usage limit; the message is shown to the user as is.
|
||||||
|
#[error("{message}")]
|
||||||
|
Limited { code: &'static str, message: String },
|
||||||
/// Birth data rejected by the horoscope service; its error object is passed through.
|
/// Birth data rejected by the horoscope service; its error object is passed through.
|
||||||
#[error("invalid birth data")]
|
#[error("invalid birth data")]
|
||||||
BirthData { status: StatusCode, body: Value },
|
BirthData { status: StatusCode, body: Value },
|
||||||
@@ -54,6 +57,7 @@ impl ApiError {
|
|||||||
ApiError::InvalidToken => (StatusCode::BAD_REQUEST, "invalid_token"),
|
ApiError::InvalidToken => (StatusCode::BAD_REQUEST, "invalid_token"),
|
||||||
ApiError::InsufficientCredits { .. } => (StatusCode::PAYMENT_REQUIRED, "insufficient_credits"),
|
ApiError::InsufficientCredits { .. } => (StatusCode::PAYMENT_REQUIRED, "insufficient_credits"),
|
||||||
ApiError::TooManyRequests => (StatusCode::TOO_MANY_REQUESTS, "too_many_requests"),
|
ApiError::TooManyRequests => (StatusCode::TOO_MANY_REQUESTS, "too_many_requests"),
|
||||||
|
ApiError::Limited { code, .. } => (StatusCode::TOO_MANY_REQUESTS, code),
|
||||||
ApiError::BirthData { status, .. } => (*status, "invalid_birth_data"),
|
ApiError::BirthData { status, .. } => (*status, "invalid_birth_data"),
|
||||||
ApiError::HoroscopeUnavailable(_) => (StatusCode::BAD_GATEWAY, "horoscope_unavailable"),
|
ApiError::HoroscopeUnavailable(_) => (StatusCode::BAD_GATEWAY, "horoscope_unavailable"),
|
||||||
ApiError::Internal(_) => (StatusCode::INTERNAL_SERVER_ERROR, "internal_error"),
|
ApiError::Internal(_) => (StatusCode::INTERNAL_SERVER_ERROR, "internal_error"),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
//! `backend healthcheck` performs a local health check (for Docker).
|
//! `backend healthcheck` performs a local health check (for Docker).
|
||||||
|
|
||||||
mod auth;
|
mod auth;
|
||||||
|
mod birth_changes;
|
||||||
mod config;
|
mod config;
|
||||||
mod credits;
|
mod credits;
|
||||||
mod error;
|
mod error;
|
||||||
|
|||||||
@@ -28,12 +28,15 @@ pub async fn me(State(state): St, auth: AuthUser) -> ApiResult<Json<Value>> {
|
|||||||
.bind(auth.id())
|
.bind(auth.id())
|
||||||
.fetch_optional(&state.db)
|
.fetch_optional(&state.db)
|
||||||
.await?;
|
.await?;
|
||||||
let balance = credits::balance(&mut *state.db.acquire().await?, auth.id()).await?;
|
let mut conn = state.db.acquire().await?;
|
||||||
|
let balance = credits::balance(&mut conn, auth.id()).await?;
|
||||||
|
let birth_change = crate::birth_changes::view(&mut conn, &auth).await?;
|
||||||
Ok(Json(json!({
|
Ok(Json(json!({
|
||||||
"user": UserView::from(&auth.user),
|
"user": UserView::from(&auth.user),
|
||||||
"providers": providers.into_iter().map(|(p,)| p).collect::<Vec<_>>(),
|
"providers": providers.into_iter().map(|(p,)| p).collect::<Vec<_>>(),
|
||||||
"primary_chart_id": primary.map(|(id,)| id),
|
"primary_chart_id": primary.map(|(id,)| id),
|
||||||
"analyses_left": balance.view(),
|
"analyses_left": balance.view(),
|
||||||
|
"birth_change": birth_change,
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! Text analyses (LLM) of charts and synastries.
|
//! Text analyses (LLM) of charts and synastries.
|
||||||
//!
|
//!
|
||||||
//! A request creates a `pending` analysis and spends one unit of its kind
|
//! A request creates a `pending` analysis and spends one unit of its kind
|
||||||
//! (`natal` or `synastry`, see [`credits`]); the worker
|
//! (`natal` or `synastry`, see [`credits`]; admins pay nothing); the worker
|
||||||
//! writes the text later. A finished analysis with the same cache key (same
|
//! writes the text later. A finished analysis with the same cache key (same
|
||||||
//! chart or synastry hash, prompt version, model and language) is copied
|
//! chart or synastry hash, prompt version, model and language) is copied
|
||||||
//! instead, free of charge, so the same chart is never paid for twice.
|
//! instead, free of charge, so the same chart is never paid for twice.
|
||||||
@@ -29,6 +29,7 @@ use crate::auth::AuthUser;
|
|||||||
use crate::credits::{self, Unit};
|
use crate::credits::{self, Unit};
|
||||||
use crate::error::{ApiError, ApiResult};
|
use crate::error::{ApiError, ApiResult};
|
||||||
use crate::views::{rfc3339, rfc3339_opt, sha256_hex};
|
use crate::views::{rfc3339, rfc3339_opt, sha256_hex};
|
||||||
|
use db::Role;
|
||||||
|
|
||||||
#[derive(Debug, Clone, sqlx::FromRow)]
|
#[derive(Debug, Clone, sqlx::FromRow)]
|
||||||
pub struct AnalysisRow {
|
pub struct AnalysisRow {
|
||||||
@@ -117,12 +118,14 @@ async fn request(
|
|||||||
req: AnalysisRequest,
|
req: AnalysisRequest,
|
||||||
) -> ApiResult<(StatusCode, Json<Value>)> {
|
) -> ApiResult<(StatusCode, Json<Value>)> {
|
||||||
let language = validate_locale(state, Some(req.language.as_deref().unwrap_or(&auth.user.locale)))?;
|
let language = validate_locale(state, Some(req.language.as_deref().unwrap_or(&auth.user.locale)))?;
|
||||||
|
// Admins get detailed analyses free of charge.
|
||||||
let unit = match target {
|
let unit = match target {
|
||||||
Target::Synastry { .. } => Unit::Synastry,
|
_ if auth.user.has_role(Role::Admin) => None,
|
||||||
_ => Unit::Natal,
|
Target::Synastry { .. } => Some(Unit::Synastry),
|
||||||
|
_ => Some(Unit::Natal),
|
||||||
};
|
};
|
||||||
let model = state.config.analysis_model.clone();
|
let model = state.config.analysis_model.clone();
|
||||||
let (status, row) = queue(state, auth.id(), &target, &language, &model, Some(unit)).await?;
|
let (status, row) = queue(state, auth.id(), &target, &language, &model, unit).await?;
|
||||||
Ok((status, Json(row.view())))
|
Ok((status, Json(row.view())))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use uuid::Uuid;
|
|||||||
use super::{Body, IdPath, St};
|
use super::{Body, IdPath, St};
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
use crate::auth::AuthUser;
|
use crate::auth::AuthUser;
|
||||||
|
use crate::birth_changes;
|
||||||
use crate::error::{ApiError, ApiResult};
|
use crate::error::{ApiError, ApiResult};
|
||||||
use crate::views::{chart_hash, chart_highlights, rfc3339};
|
use crate::views::{chart_hash, chart_highlights, rfc3339};
|
||||||
|
|
||||||
@@ -130,7 +131,8 @@ fn clean_birth(birth: Value) -> Result<Value, ApiError> {
|
|||||||
|
|
||||||
/// Saves a new chart. If the user already has a chart with exactly the same
|
/// Saves a new chart. If the user already has a chart with exactly the same
|
||||||
/// birth data, that one is returned (and made primary if asked) instead of
|
/// birth data, that one is returned (and made primary if asked) instead of
|
||||||
/// calculating it again.
|
/// calculating it again. Replacing the user's own chart counts against the
|
||||||
|
/// birth data change limit ([`birth_changes`]).
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
State(state): St,
|
State(state): St,
|
||||||
auth: AuthUser,
|
auth: AuthUser,
|
||||||
@@ -157,6 +159,7 @@ pub async fn create(
|
|||||||
.bind(chart.id)
|
.bind(chart.id)
|
||||||
.fetch_one(&mut *tx)
|
.fetch_one(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
birth_changes::record(&mut tx, &auth, row.id).await?;
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
queue_summary(&state, &auth, &row).await;
|
queue_summary(&state, &auth, &row).await;
|
||||||
return Ok((StatusCode::OK, Json(row.owner_view())));
|
return Ok((StatusCode::OK, Json(row.owner_view())));
|
||||||
@@ -194,6 +197,9 @@ pub async fn create(
|
|||||||
.bind(hash)
|
.bind(hash)
|
||||||
.fetch_one(&mut *tx)
|
.fetch_one(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
if req.is_primary {
|
||||||
|
birth_changes::record(&mut tx, &auth, row.id).await?;
|
||||||
|
}
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
queue_summary(&state, &auth, &row).await;
|
queue_summary(&state, &auth, &row).await;
|
||||||
Ok((StatusCode::CREATED, Json(row.owner_view())))
|
Ok((StatusCode::CREATED, Json(row.owner_view())))
|
||||||
@@ -243,6 +249,9 @@ pub async fn update(
|
|||||||
.bind(id)
|
.bind(id)
|
||||||
.fetch_one(&mut *tx)
|
.fetch_one(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
|
if is_primary && !chart.is_primary {
|
||||||
|
birth_changes::record(&mut tx, &auth, id).await?;
|
||||||
|
}
|
||||||
tx.commit().await?;
|
tx.commit().await?;
|
||||||
Ok(Json(row.owner_view()))
|
Ok(Json(row.owner_view()))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ mod admin;
|
|||||||
mod analyses;
|
mod analyses;
|
||||||
mod auth;
|
mod auth;
|
||||||
mod charts;
|
mod charts;
|
||||||
|
mod payments;
|
||||||
mod shares;
|
mod shares;
|
||||||
mod synastries;
|
mod synastries;
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ pub fn router(state: Arc<AppState>) -> Router {
|
|||||||
.route("/v1/me/password", post(account::change_password))
|
.route("/v1/me/password", post(account::change_password))
|
||||||
.route("/v1/me/export", get(account::export))
|
.route("/v1/me/export", get(account::export))
|
||||||
.route("/v1/credits", get(account::credits))
|
.route("/v1/credits", get(account::credits))
|
||||||
|
.route("/v1/payments/mock", post(payments::mock))
|
||||||
// charts
|
// charts
|
||||||
.route("/v1/charts", get(charts::list).post(charts::create))
|
.route("/v1/charts", get(charts::list).post(charts::create))
|
||||||
.route("/v1/charts/{id}", get(charts::get_one).patch(charts::update).delete(charts::remove))
|
.route("/v1/charts/{id}", get(charts::get_one).patch(charts::update).delete(charts::remove))
|
||||||
@@ -119,6 +121,7 @@ async fn public_config(State(state): St) -> Json<Value> {
|
|||||||
"analysis_model": c.analysis_model,
|
"analysis_model": c.analysis_model,
|
||||||
"summary_model": c.summary_model,
|
"summary_model": c.summary_model,
|
||||||
"password_login": c.password_login,
|
"password_login": c.password_login,
|
||||||
|
"mock_payments": c.mock_payments,
|
||||||
"password_min_length": crate::auth::MIN_PASSWORD_LEN,
|
"password_min_length": crate::auth::MIN_PASSWORD_LEN,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
//! Payments. Until Stripe is connected, `MOCK_PAYMENTS=true` turns on a
|
||||||
|
//! stand-in: "paying" adds one analysis unit right away, so the paid flow can
|
||||||
|
//! be used end to end.
|
||||||
|
|
||||||
|
use axum::Json;
|
||||||
|
use axum::extract::State;
|
||||||
|
use axum_extra::extract::WithRejection;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use super::{Body, St};
|
||||||
|
use crate::auth::AuthUser;
|
||||||
|
use crate::credits::{self, Unit};
|
||||||
|
use crate::error::{ApiError, ApiResult};
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct MockPayment {
|
||||||
|
unit: Unit,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds one unit of the given kind as a (pretend) purchase.
|
||||||
|
pub async fn mock(
|
||||||
|
State(state): St,
|
||||||
|
auth: AuthUser,
|
||||||
|
WithRejection(Json(req), _): Body<MockPayment>,
|
||||||
|
) -> ApiResult<Json<Value>> {
|
||||||
|
if !state.config.mock_payments {
|
||||||
|
return Err(ApiError::NotFound("payment method"));
|
||||||
|
}
|
||||||
|
let mut tx = state.db.begin().await?;
|
||||||
|
sqlx::query(
|
||||||
|
"INSERT INTO credit_ledger (id, user_id, unit, delta, reason, note) VALUES ($1, $2, $3, 1, 'purchase', 'mock payment')",
|
||||||
|
)
|
||||||
|
.bind(Uuid::now_v7())
|
||||||
|
.bind(auth.id())
|
||||||
|
.bind(req.unit.as_str())
|
||||||
|
.execute(&mut *tx)
|
||||||
|
.await?;
|
||||||
|
let balance = credits::balance(&mut tx, auth.id()).await?;
|
||||||
|
tx.commit().await?;
|
||||||
|
Ok(Json(json!({ "analyses_left": balance.view() })))
|
||||||
|
}
|
||||||
@@ -400,6 +400,8 @@ async fn charts_are_private(pool: PgPool) {
|
|||||||
.await;
|
.await;
|
||||||
assert_eq!((r.status, r.body["error"]["code"].as_str()), (StatusCode::NOT_FOUND, Some("place_not_found")));
|
assert_eq!((r.status, r.body["error"]["code"].as_str()), (StatusCode::NOT_FOUND, Some("place_not_found")));
|
||||||
|
|
||||||
|
// (the fourth change of the own chart; the limit is tested in birth_data_changes_are_limited)
|
||||||
|
sqlx::query("DELETE FROM birth_data_changes").execute(&app.pool).await.unwrap();
|
||||||
let r = app
|
let r = app
|
||||||
.call("PATCH", &format!("/v1/charts/{id}"), Some(&anna), Some(json!({"label": "Én", "is_primary": true})))
|
.call("PATCH", &format!("/v1/charts/{id}"), Some(&anna), Some(json!({"label": "Én", "is_primary": true})))
|
||||||
.await;
|
.await;
|
||||||
@@ -652,3 +654,101 @@ async fn synastry_analyses_use_synastry_units(pool: PgPool) {
|
|||||||
assert_eq!((r.status, r.body["kind"].as_str()), (StatusCode::ACCEPTED, Some("synastry")));
|
assert_eq!((r.status, r.body["kind"].as_str()), (StatusCode::ACCEPTED, Some("synastry")));
|
||||||
assert_eq!(app.get("/v1/credits", Some(&anna)).await.body["balance"], json!({"natal": 1, "synastry": 0}));
|
assert_eq!(app.get("/v1/credits", Some(&anna)).await.body["balance"], json!({"natal": 1, "synastry": 0}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||||
|
async fn birth_data_changes_are_limited(pool: PgPool) {
|
||||||
|
let app = TestApp::new(pool.clone()).await;
|
||||||
|
let anna = app.register("anna@example.com", "Anna").await;
|
||||||
|
assert_eq!(app.get("/v1/me", Some(&anna)).await.body["birth_change"]["limited"], json!(false));
|
||||||
|
|
||||||
|
// the first save and three corrections within the hour are free
|
||||||
|
let first = app.chart(&anna, "Saját", true, "1990-03-15").await;
|
||||||
|
for date in ["1990-03-16", "1990-03-17", "1990-03-18"] {
|
||||||
|
app.chart(&anna, "Saját", true, date).await;
|
||||||
|
}
|
||||||
|
// saving the current data again is not a change
|
||||||
|
let r = app
|
||||||
|
.post(
|
||||||
|
"/v1/charts",
|
||||||
|
Some(&anna),
|
||||||
|
json!({"label": "Saját", "is_primary": true,
|
||||||
|
"birth": {"date": "1990-03-18", "time": "14:30", "country": "HU", "place": "Szeged"}}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
|
||||||
|
|
||||||
|
// the fourth correction: once a day from now on
|
||||||
|
let r = app
|
||||||
|
.post(
|
||||||
|
"/v1/charts",
|
||||||
|
Some(&anna),
|
||||||
|
json!({"label": "Saját", "is_primary": true,
|
||||||
|
"birth": {"date": "1990-03-19", "time": "14:30", "country": "HU", "place": "Szeged"}}),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(r.status, StatusCode::TOO_MANY_REQUESTS, "{}", r.body);
|
||||||
|
assert_eq!(r.body["error"]["code"], json!("birth_data_change_limit"));
|
||||||
|
let message = r.body["error"]["message"].as_str().unwrap();
|
||||||
|
assert!(message.starts_with("A rendszer csak napi egy módosítást engedélyez."), "{message}");
|
||||||
|
assert!(message.ends_with("óra múlva módosíthatod."), "{message}");
|
||||||
|
// switching back to an older chart is a change too
|
||||||
|
let r = app
|
||||||
|
.call(
|
||||||
|
"PATCH",
|
||||||
|
&format!("/v1/charts/{}", first["id"].as_str().unwrap()),
|
||||||
|
Some(&anna),
|
||||||
|
Some(json!({"is_primary": true})),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
assert_eq!(r.status, StatusCode::TOO_MANY_REQUESTS);
|
||||||
|
// other people's charts are not limited
|
||||||
|
app.chart(&anna, "Béla", false, "1985-08-02").await;
|
||||||
|
|
||||||
|
let me = app.get("/v1/me", Some(&anna)).await.body;
|
||||||
|
assert_eq!(me["birth_change"]["limited"], json!(true));
|
||||||
|
assert!(me["birth_change"]["notice"].as_str().unwrap().contains("napi egy"));
|
||||||
|
|
||||||
|
// a day later it works again
|
||||||
|
sqlx::query("UPDATE birth_data_changes SET created_at = created_at - interval '25 hours'")
|
||||||
|
.execute(&pool)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
app.chart(&anna, "Saját", true, "1990-03-19").await;
|
||||||
|
|
||||||
|
// admins are not limited
|
||||||
|
let admin = app.register("admin@example.com", "Admin").await;
|
||||||
|
for day in 10..16 {
|
||||||
|
app.chart(&admin, "Saját", true, &format!("1980-01-{day}")).await;
|
||||||
|
}
|
||||||
|
assert_eq!(app.get("/v1/me", Some(&admin)).await.body["birth_change"]["notice"], Value::Null);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[sqlx::test(migrator = "db::MIGRATOR")]
|
||||||
|
async fn admins_get_free_analyses_and_mock_payments_add_units(pool: PgPool) {
|
||||||
|
let app = TestApp::new(pool).await;
|
||||||
|
let admin = app.register("admin@example.com", "Admin").await;
|
||||||
|
let chart = app.chart(&admin, "Saját", true, "1990-03-15").await;
|
||||||
|
let r =
|
||||||
|
app.call("POST", &format!("/v1/charts/{}/analyses", chart["id"].as_str().unwrap()), Some(&admin), None).await;
|
||||||
|
assert_eq!((r.status, &r.body["credits_charged"]), (StatusCode::ACCEPTED, &json!(0)), "{}", r.body);
|
||||||
|
|
||||||
|
// a user "pays", which adds a unit, then requests the analysis
|
||||||
|
let anna = app.register("anna@example.com", "Anna").await;
|
||||||
|
let chart = app.chart(&anna, "Saját", true, "1991-05-01").await;
|
||||||
|
let r = app.post("/v1/payments/mock", Some(&anna), json!({"unit": "natal"})).await;
|
||||||
|
assert_eq!(
|
||||||
|
(r.status, &r.body["analyses_left"]),
|
||||||
|
(StatusCode::OK, &json!({"natal": 1, "synastry": 0})),
|
||||||
|
"{}",
|
||||||
|
r.body
|
||||||
|
);
|
||||||
|
let r =
|
||||||
|
app.call("POST", &format!("/v1/charts/{}/analyses", chart["id"].as_str().unwrap()), Some(&anna), None).await;
|
||||||
|
assert_eq!((r.status, &r.body["credits_charged"]), (StatusCode::ACCEPTED, &json!(1)), "{}", r.body);
|
||||||
|
assert_eq!(app.get("/v1/credits", Some(&anna)).await.body["balance"], json!({"natal": 0, "synastry": 0}));
|
||||||
|
|
||||||
|
// without MOCK_PAYMENTS there is no such payment
|
||||||
|
let app = TestApp::with_config(app.pool.clone(), |c| c.mock_payments = false).await;
|
||||||
|
let r = app.post("/v1/payments/mock", Some(&anna), json!({"unit": "natal"})).await;
|
||||||
|
assert_eq!(r.status, StatusCode::NOT_FOUND);
|
||||||
|
}
|
||||||
|
|||||||
@@ -192,6 +192,21 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|||||||
.skeleton span:last-child { width: 60%; }
|
.skeleton span:last-child { width: 60%; }
|
||||||
@keyframes pulse { 50% { opacity: 0.45; } }
|
@keyframes pulse { 50% { opacity: 0.45; } }
|
||||||
@media (prefers-reduced-motion: reduce) { .skeleton span { animation: none; } }
|
@media (prefers-reduced-motion: reduce) { .skeleton span { animation: none; } }
|
||||||
|
|
||||||
|
/* Loading while the LLM writes */
|
||||||
|
.loading { display: flex; align-items: center; gap: 24px; padding: 8px 0; }
|
||||||
|
.loading-wheel { width: 120px; height: 120px; flex: none; animation: spin 24s linear infinite; }
|
||||||
|
.loading-compact .loading-wheel { width: 64px; height: 64px; }
|
||||||
|
.loading-text { display: flex; flex-direction: column; gap: 6px; }
|
||||||
|
.loading-text strong { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
|
||||||
|
.loading-text .muted { animation: pulse 2.4s ease-in-out infinite; }
|
||||||
|
@keyframes spin { to { transform: rotate(360deg); } }
|
||||||
|
@media (prefers-reduced-motion: reduce) { .loading-wheel, .loading-text .muted { animation: none; } }
|
||||||
|
@media (max-width: 640px) { .loading { flex-direction: column; text-align: center; } }
|
||||||
|
|
||||||
|
/* Payment step */
|
||||||
|
.pay-box { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); }
|
||||||
|
.pay-line { display: flex; justify-content: space-between; gap: 12px; }
|
||||||
.chart-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
|
.chart-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
|
||||||
.chart-wheel-card { padding: 16px; gap: 10px; }
|
.chart-wheel-card { padding: 16px; gap: 10px; }
|
||||||
.chart-wheel { width: 100%; height: auto; display: block; max-width: 680px; margin: 0 auto; }
|
.chart-wheel { width: 100%; height: auto; display: block; max-width: 680px; margin: 0 auto; }
|
||||||
@@ -224,13 +239,10 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|||||||
.w-axis-label { fill: var(--gold); font: 600 14px var(--font-body); letter-spacing: 0.5px; }
|
.w-axis-label { fill: var(--gold); font: 600 14px var(--font-body); letter-spacing: 0.5px; }
|
||||||
.w-house-num { fill: var(--muted); font: 500 12px var(--font-body); }
|
.w-house-num { fill: var(--muted); font: 500 12px var(--font-body); }
|
||||||
.w-aspect { stroke-linecap: round; }
|
.w-aspect { stroke-linecap: round; }
|
||||||
.w-aspect { transition: stroke-opacity 0.15s; }
|
|
||||||
.w-asp-trine { stroke: var(--harmonic); }
|
.w-asp-trine { stroke: var(--harmonic); }
|
||||||
.w-asp-sextile { stroke: var(--harmonic); stroke-dasharray: 5 4; }
|
.w-asp-sextile { stroke: var(--harmonic); stroke-dasharray: 5 4; }
|
||||||
.w-asp-square { stroke: var(--square); }
|
.w-asp-square { stroke: var(--square); }
|
||||||
.w-asp-opposition { stroke: var(--tense); }
|
.w-asp-opposition { stroke: var(--tense); }
|
||||||
.w-point { outline: none; cursor: default; }
|
|
||||||
.w-point:focus-visible .w-point-glyph { fill: var(--gold); }
|
|
||||||
.w-point-tick { stroke: var(--ink); stroke-width: 1.6; }
|
.w-point-tick { stroke: var(--ink); stroke-width: 1.6; }
|
||||||
.w-leader { stroke: var(--muted); stroke-width: 0.7; stroke-opacity: 0.6; }
|
.w-leader { stroke: var(--muted); stroke-width: 0.7; stroke-opacity: 0.6; }
|
||||||
.w-point-glyph { fill: var(--ink); font-family: var(--font-symbols); font-size: 22px; }
|
.w-point-glyph { fill: var(--ink); font-family: var(--font-symbols); font-size: 22px; }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import Link from "next/link";
|
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
|
|
||||||
import { BigThree, ChartTables } from "@/components/ChartTables";
|
import { BigThree, ChartTables } from "@/components/ChartTables";
|
||||||
@@ -8,7 +7,7 @@ import { DetailedAnalysis } from "@/components/DetailedAnalysis";
|
|||||||
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
|
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
|
||||||
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
|
||||||
import { backendGet, requireMe } from "@/lib/server";
|
import { backendGet, requireMe } from "@/lib/server";
|
||||||
import type { Analysis, Chart } from "@/lib/types";
|
import type { Analysis, Chart, PublicConfig } from "@/lib/types";
|
||||||
|
|
||||||
export const metadata: Metadata = { title: "Képlet" };
|
export const metadata: Metadata = { title: "Képlet" };
|
||||||
|
|
||||||
@@ -19,9 +18,10 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
|||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
const me = await requireMe(`/kepletek/${id}`);
|
const me = await requireMe(`/kepletek/${id}`);
|
||||||
if (!UUID.test(id)) notFound();
|
if (!UUID.test(id)) notFound();
|
||||||
const [chart, analyses] = await Promise.all([
|
const [chart, analyses, config] = await Promise.all([
|
||||||
backendGet<Chart>(`/v1/charts/${id}`),
|
backendGet<Chart>(`/v1/charts/${id}`),
|
||||||
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
|
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
|
||||||
|
backendGet<PublicConfig>("/v1/config"),
|
||||||
]);
|
]);
|
||||||
if (!chart) notFound();
|
if (!chart) notFound();
|
||||||
const list = analyses?.analyses ?? [];
|
const list = analyses?.analyses ?? [];
|
||||||
@@ -47,12 +47,6 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
|||||||
{" · "}
|
{" · "}
|
||||||
{place?.name ?? chart.birth_data.place ?? "–"}
|
{place?.name ?? chart.birth_data.place ?? "–"}
|
||||||
{country ? `, ${countryName(country)}` : ""}
|
{country ? `, ${countryName(country)}` : ""}
|
||||||
{chart.is_primary && (
|
|
||||||
<>
|
|
||||||
{" · "}
|
|
||||||
<Link href="/profil#birth">adatok javítása</Link>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -111,7 +105,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<DetailedAnalysis chartId={chart.id} initial={detailed} left={me.analyses_left.natal} />
|
<DetailedAnalysis
|
||||||
|
chartId={chart.id}
|
||||||
|
initial={detailed}
|
||||||
|
left={me.analyses_left.natal}
|
||||||
|
isAdmin={me.user.roles.includes("admin")}
|
||||||
|
canPay={config?.mock_payments ?? false}
|
||||||
|
/>
|
||||||
|
|
||||||
<section className="card" aria-labelledby="positions">
|
<section className="card" aria-labelledby="positions">
|
||||||
<h2 id="positions">Pozíciók</h2>
|
<h2 id="positions">Pozíciók</h2>
|
||||||
|
|||||||
@@ -19,8 +19,19 @@ export interface SavedBirth {
|
|||||||
dst: boolean;
|
dst: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Shows the saved birth data, or the form to enter or correct it. Saving opens the chart page. */
|
/**
|
||||||
export function BirthEditor({ chart, chartId }: { chart: SavedBirth | null; chartId: string | null }) {
|
* Shows the saved birth data, or the form to enter or correct it. Saving opens
|
||||||
|
* the chart page. `notice`: the backend's text about the change limit, if any.
|
||||||
|
*/
|
||||||
|
export function BirthEditor({
|
||||||
|
chart,
|
||||||
|
chartId,
|
||||||
|
notice,
|
||||||
|
}: {
|
||||||
|
chart: SavedBirth | null;
|
||||||
|
chartId: string | null;
|
||||||
|
notice: string | null;
|
||||||
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [editing, setEditing] = useState(chart === null);
|
const [editing, setEditing] = useState(chart === null);
|
||||||
|
|
||||||
@@ -38,6 +49,7 @@ export function BirthEditor({ chart, chartId }: { chart: SavedBirth | null; char
|
|||||||
időszámítást) a születési hely alapján magunk határozzuk meg.
|
időszámítást) a születési hely alapján magunk határozzuk meg.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{chart && notice && <p className="msg">{notice}</p>}
|
||||||
<BirthForm
|
<BirthForm
|
||||||
initial={chart ? { ...chart.birth, placeName: chart.placeName, region: chart.region } : null}
|
initial={chart ? { ...chart.birth, placeName: chart.placeName, region: chart.region } : null}
|
||||||
onCancel={chart ? () => setEditing(false) : undefined}
|
onCancel={chart ? () => setEditing(false) : undefined}
|
||||||
@@ -87,6 +99,7 @@ export function BirthEditor({ chart, chartId }: { chart: SavedBirth | null; char
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{notice && <p className="hint">{notice}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ export default async function ProfilePage() {
|
|||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
chartId={chart?.id ?? null}
|
chartId={chart?.id ?? null}
|
||||||
|
notice={me.birth_change.notice}
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import { ZodiacWheel } from "./ZodiacWheel";
|
||||||
|
|
||||||
|
/** Slowly turning wheel with the elapsed time, while the LLM writes. */
|
||||||
|
export function AnalysisLoading({ title, text, compact = false }: { title?: string; text: string; compact?: boolean }) {
|
||||||
|
const [seconds, setSeconds] = useState(0);
|
||||||
|
useEffect(() => {
|
||||||
|
const t = setInterval(() => setSeconds((s) => s + 1), 1000);
|
||||||
|
return () => clearInterval(t);
|
||||||
|
}, []);
|
||||||
|
const elapsed = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={compact ? "loading loading-compact" : "loading"}>
|
||||||
|
<ZodiacWheel className="loading-wheel" />
|
||||||
|
<div className="loading-text">
|
||||||
|
{title && <strong>{title}</strong>}
|
||||||
|
<p className="muted" role="status">
|
||||||
|
{text}
|
||||||
|
</p>
|
||||||
|
<p className="hint" aria-hidden="true">
|
||||||
|
{elapsed}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { api } from "@/lib/api";
|
import { api } from "@/lib/api";
|
||||||
import type { Analysis } from "@/lib/types";
|
import type { Analysis } from "@/lib/types";
|
||||||
|
|
||||||
|
import { AnalysisLoading } from "./AnalysisLoading";
|
||||||
import { Rich } from "./Rich";
|
import { Rich } from "./Rich";
|
||||||
|
|
||||||
const POLL_MS = 3000;
|
const POLL_MS = 3000;
|
||||||
@@ -62,17 +63,12 @@ export function ChartSummary({ chartId, initial }: { chartId: string; initial: A
|
|||||||
<h2 id="summary-title" className="sr-only">
|
<h2 id="summary-title" className="sr-only">
|
||||||
Rövid összefoglaló
|
Rövid összefoglaló
|
||||||
</h2>
|
</h2>
|
||||||
|
{gaveUp || summary?.status === "failed" ? (
|
||||||
<p className="muted" role="status">
|
<p className="muted" role="status">
|
||||||
{gaveUp || summary?.status === "failed"
|
Az összefoglaló most nem készült el. Töltsd újra az oldalt egy kicsit később.
|
||||||
? "Az összefoglaló most nem készült el. Töltsd újra az oldalt egy kicsit később."
|
|
||||||
: "Az összefoglalód készül, ez néhány másodperc…"}
|
|
||||||
</p>
|
</p>
|
||||||
{!gaveUp && summary?.status !== "failed" && (
|
) : (
|
||||||
<div className="skeleton" aria-hidden="true">
|
<AnalysisLoading compact text="Az összefoglalód készül, ez néhány másodperc…" />
|
||||||
<span />
|
|
||||||
<span />
|
|
||||||
<span />
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -116,13 +116,6 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
|
|||||||
.filter((a) => WHEEL_ASPECTS.includes(a.aspect) && ends.has(a.point1) && ends.has(a.point2))
|
.filter((a) => WHEEL_ASPECTS.includes(a.aspect) && ends.has(a.point1) && ends.has(a.point2))
|
||||||
.map((a) => ({ ...a, strength: a.max_orb > 0 ? 1 - Math.min(a.orb / a.max_orb, 1) : 0.5 }))
|
.map((a) => ({ ...a, strength: a.max_orb > 0 ? 1 - Math.min(a.orb / a.max_orb, 1) : 0.5 }))
|
||||||
.sort((x, y) => x.strength - y.strength);
|
.sort((x, y) => x.strength - y.strength);
|
||||||
// Hovering or focusing a point shows only its aspects.
|
|
||||||
const highlight = [...ends.keys()]
|
|
||||||
.map((id) => {
|
|
||||||
const on = `.chart-wheel:has(.p-${id}:hover, .p-${id}:focus-visible)`;
|
|
||||||
return `${on} .w-aspect:not(.a-${id}){stroke-opacity:0.06}${on} .w-aspect.a-${id}{stroke-opacity:1}`;
|
|
||||||
})
|
|
||||||
.join("\n");
|
|
||||||
|
|
||||||
const description = points
|
const description = points
|
||||||
.map((p) => `${pointName(p.id)} ${signName(p.sign)} ${dms(p.degree_in_sign_dms)}`)
|
.map((p) => `${pointName(p.id)} ${signName(p.sign)} ${dms(p.degree_in_sign_dms)}`)
|
||||||
@@ -192,7 +185,7 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
|
|||||||
key={key}
|
key={key}
|
||||||
x={f(x)}
|
x={f(x)}
|
||||||
y={f(y)}
|
y={f(y)}
|
||||||
className={`w-axis-label p-${key}`}
|
className="w-axis-label"
|
||||||
dominantBaseline="central"
|
dominantBaseline="central"
|
||||||
textAnchor="middle"
|
textAnchor="middle"
|
||||||
>
|
>
|
||||||
@@ -207,7 +200,6 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Aspects */}
|
{/* Aspects */}
|
||||||
<style>{highlight}</style>
|
|
||||||
<circle cx={C} cy={C} r={R_INNER} className="w-ring w-inner" />
|
<circle cx={C} cy={C} r={R_INNER} className="w-ring w-inner" />
|
||||||
{aspects.map((a) => {
|
{aspects.map((a) => {
|
||||||
const [x1, y1] = xy(ends.get(a.point1)!, R_INNER, start);
|
const [x1, y1] = xy(ends.get(a.point1)!, R_INNER, start);
|
||||||
@@ -220,7 +212,7 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
|
|||||||
y1={f(y1)}
|
y1={f(y1)}
|
||||||
x2={f(x2)}
|
x2={f(x2)}
|
||||||
y2={f(y2)}
|
y2={f(y2)}
|
||||||
className={`w-aspect w-asp-${a.aspect} a-${a.point1} a-${a.point2}`}
|
className={`w-aspect w-asp-${a.aspect}`}
|
||||||
strokeOpacity={(0.2 + 0.8 * s * s).toFixed(2)}
|
strokeOpacity={(0.2 + 0.8 * s * s).toFixed(2)}
|
||||||
strokeWidth={(0.6 + 1.9 * s).toFixed(2)}
|
strokeWidth={(0.6 + 1.9 * s).toFixed(2)}
|
||||||
>
|
>
|
||||||
@@ -242,7 +234,7 @@ export function ChartWheel({ chart, timeKnown }: { chart: ChartResult; timeKnown
|
|||||||
const [ex, ey] = xy(placed[i], R_INNER, start);
|
const [ex, ey] = xy(placed[i], R_INNER, start);
|
||||||
const deg = Number.parseInt(p.degree_in_sign_dms, 10);
|
const deg = Number.parseInt(p.degree_in_sign_dms, 10);
|
||||||
return (
|
return (
|
||||||
<g key={p.id} className={`w-point p-${p.id}`} tabIndex={0}>
|
<g key={p.id} className="w-point">
|
||||||
<title>
|
<title>
|
||||||
{pointName(p.id)}: {dms(p.degree_in_sign_dms)} {signName(p.sign)}
|
{pointName(p.id)}: {dms(p.degree_in_sign_dms)} {signName(p.sign)}
|
||||||
{p.retrograde ? ", retrográd" : ""}
|
{p.retrograde ? ", retrográd" : ""}
|
||||||
@@ -282,7 +274,7 @@ export function WheelLegend() {
|
|||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</p>
|
</p>
|
||||||
<p>Vastagabb vonal: szorosabb fényszög. Egy bolygóra mutatva csak az ő fényszögei látszanak.</p>
|
<p>Vastagabb vonal: szorosabb fényszög.</p>
|
||||||
<p>A körön a bolygók, az ASC és az MC főfényszögei vannak; az összes fényszög a táblázatban.</p>
|
<p>A körön a bolygók, az ASC és az MC főfényszögei vannak; az összes fényszög a táblázatban.</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,27 +6,35 @@ import { useEffect, useState } from "react";
|
|||||||
import { api, errorText } from "@/lib/api";
|
import { api, errorText } from "@/lib/api";
|
||||||
import type { Analysis } from "@/lib/types";
|
import type { Analysis } from "@/lib/types";
|
||||||
|
|
||||||
|
import { AnalysisLoading } from "./AnalysisLoading";
|
||||||
import { AnalysisView } from "./AnalysisView";
|
import { AnalysisView } from "./AnalysisView";
|
||||||
|
|
||||||
const POLL_MS = 5000;
|
const POLL_MS = 5000;
|
||||||
const MAX_POLLS = 120; // 10 minutes
|
const MAX_POLLS = 120; // 10 minutes
|
||||||
|
|
||||||
|
type Step = "offer" | "confirm" | "pay";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The paid detailed analysis of a chart: offer (with the units left),
|
* The detailed analysis of a chart. A saved one is shown at once; otherwise
|
||||||
* confirmation, progress while the worker writes it, and the finished text.
|
* the offer: admins start it free, users with units confirm, others pay
|
||||||
|
* (a stand-in payment for now). While the worker writes it, a loading wheel.
|
||||||
*/
|
*/
|
||||||
export function DetailedAnalysis({
|
export function DetailedAnalysis({
|
||||||
chartId,
|
chartId,
|
||||||
initial,
|
initial,
|
||||||
left,
|
left,
|
||||||
|
isAdmin,
|
||||||
|
canPay,
|
||||||
}: {
|
}: {
|
||||||
chartId: string;
|
chartId: string;
|
||||||
initial: Analysis | null;
|
initial: Analysis | null;
|
||||||
left: number;
|
left: number;
|
||||||
|
isAdmin: boolean;
|
||||||
|
/** The stand-in payment is on (MOCK_PAYMENTS). */
|
||||||
|
canPay: boolean;
|
||||||
}) {
|
}) {
|
||||||
const [analysis, setAnalysis] = useState<Analysis | null>(initial);
|
const [analysis, setAnalysis] = useState<Analysis | null>(initial);
|
||||||
const [remaining, setRemaining] = useState(left);
|
const [step, setStep] = useState<Step>("offer");
|
||||||
const [confirming, setConfirming] = useState(false);
|
|
||||||
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 waiting = analysis?.status === "pending" || analysis?.status === "running";
|
const waiting = analysis?.status === "pending" || analysis?.status === "running";
|
||||||
@@ -54,14 +62,13 @@ export function DetailedAnalysis({
|
|||||||
};
|
};
|
||||||
}, [waiting, analysis]);
|
}, [waiting, analysis]);
|
||||||
|
|
||||||
async function request() {
|
async function start(pay: boolean) {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
try {
|
try {
|
||||||
const next = await api<Analysis>(`/charts/${chartId}/analyses`, { method: "POST" });
|
if (pay) await api("/payments/mock", { body: { unit: "natal" } });
|
||||||
setAnalysis(next);
|
setAnalysis(await api<Analysis>(`/charts/${chartId}/analyses`, { method: "POST" }));
|
||||||
if (next.credits_charged > 0) setRemaining((n) => n - 1);
|
setStep("offer");
|
||||||
setConfirming(false);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(errorText(e));
|
setError(errorText(e));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -78,32 +85,29 @@ export function DetailedAnalysis({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (waiting) {
|
||||||
return (
|
return (
|
||||||
<section className="card analysis-card" aria-labelledby="detailed-title" aria-busy={waiting}>
|
<section className="card analysis-card" aria-label="Részletes elemzés" aria-busy="true">
|
||||||
|
<span className="eyebrow">Részletes elemzés</span>
|
||||||
|
<AnalysisLoading
|
||||||
|
title="Készül az elemzésed"
|
||||||
|
text="Most íródik a hat fejezet a képleted alapján. Ez általában 1–3 perc; nyugodtan elhagyhatod az oldalt, az elemzés elkészül és itt vár."
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="card analysis-card" aria-labelledby="detailed-title">
|
||||||
<span className="eyebrow">Részletes elemzés</span>
|
<span className="eyebrow">Részletes elemzés</span>
|
||||||
{waiting ? (
|
|
||||||
<>
|
|
||||||
<h2 id="detailed-title">Készül az elemzésed</h2>
|
|
||||||
<p className="muted" role="status">
|
|
||||||
A mesterséges intelligencia most írja meg a hat fejezetet a képleted alapján. Ez általában 1–2 perc; nyugodtan
|
|
||||||
elhagyhatod az oldalt, az elemzés elkészül és itt vár.
|
|
||||||
</p>
|
|
||||||
<div className="skeleton" aria-hidden="true">
|
|
||||||
<span />
|
|
||||||
<span />
|
|
||||||
<span />
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
|
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
|
||||||
<p className="muted">
|
<p className="muted">
|
||||||
Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési
|
Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési út.
|
||||||
út. A végén erősségek, kihívások és útravaló. Csak a képleted pozíciói alapján készül.
|
A végén erősségek, kihívások és útravaló. Csak a képleted pozíciói alapján készül.
|
||||||
</p>
|
</p>
|
||||||
{analysis?.status === "failed" && (
|
{analysis?.status === "failed" && (
|
||||||
<p className="msg msg-error" role="alert">
|
<p className="msg msg-error" role="alert">
|
||||||
Az előző kérés nem sikerült, az elemzést visszaadtuk a keretedbe. Próbáld újra.
|
Az előző kérés nem sikerült{isAdmin ? "" : ", az elemzést visszaadtuk a keretedbe"}. Próbáld újra.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{error && (
|
{error && (
|
||||||
@@ -111,23 +115,58 @@ export function DetailedAnalysis({
|
|||||||
{error}
|
{error}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{remaining > 0 ? (
|
|
||||||
confirming ? (
|
{isAdmin ? (
|
||||||
<div className="form-actions">
|
<div className="form-actions">
|
||||||
<button type="button" className="btn btn-primary" onClick={request} disabled={busy}>
|
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
|
||||||
|
{busy ? "Indítás…" : "Részletes elemzés készítése"}
|
||||||
|
</button>
|
||||||
|
<span className="hint">Adminként ingyenes.</span>
|
||||||
|
</div>
|
||||||
|
) : left > 0 ? (
|
||||||
|
step === "confirm" ? (
|
||||||
|
<div className="form-actions">
|
||||||
|
<button type="button" className="btn btn-primary" onClick={() => start(false)} disabled={busy}>
|
||||||
{busy ? "Indítás…" : "Igen, kérem az elemzést"}
|
{busy ? "Indítás…" : "Igen, kérem az elemzést"}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" className="btn btn-ghost" onClick={() => setConfirming(false)} disabled={busy}>
|
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
|
||||||
Mégse
|
Mégse
|
||||||
</button>
|
</button>
|
||||||
<span className="hint">Ez felhasznál 1-et a {remaining} képletelemzésedből.</span>
|
<span className="hint">Ez felhasznál 1-et a {left} képletelemzésedből.</span>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="form-actions">
|
<div className="form-actions">
|
||||||
<button type="button" className="btn btn-primary" onClick={() => setConfirming(true)}>
|
<button type="button" className="btn btn-primary" onClick={() => setStep("confirm")}>
|
||||||
Részletes elemzés kérése
|
Részletes elemzés kérése
|
||||||
</button>
|
</button>
|
||||||
<span className="hint">Még {remaining} képletelemzésed van.</span>
|
<span className="hint">Még {left} képletelemzésed van.</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
) : canPay ? (
|
||||||
|
step === "pay" ? (
|
||||||
|
<div className="pay-box">
|
||||||
|
<div className="pay-line">
|
||||||
|
<span>Részletes képletelemzés</span>
|
||||||
|
<strong>1 db</strong>
|
||||||
|
</div>
|
||||||
|
<div className="form-actions">
|
||||||
|
<button type="button" className="btn btn-primary" onClick={() => start(true)} disabled={busy}>
|
||||||
|
{busy ? "Fizetés…" : "Fizetés"}
|
||||||
|
</button>
|
||||||
|
<button type="button" className="btn btn-ghost" onClick={() => setStep("offer")} disabled={busy}>
|
||||||
|
Mégse
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p className="hint">Tesztüzem: a fizetés még nincs bekötve, a gomb nem terhel semmit.</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="form-actions">
|
||||||
|
<button type="button" className="btn btn-primary" onClick={() => setStep("pay")}>
|
||||||
|
Részletes elemzés kérése
|
||||||
|
</button>
|
||||||
|
<Link href="/pelda" className="btn btn-ghost">
|
||||||
|
Példa megtekintése
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
@@ -138,8 +177,6 @@ export function DetailedAnalysis({
|
|||||||
<span className="hint">A részletes elemzés fizetős; a csomagok hamarosan elérhetők.</span>
|
<span className="hint">A részletes elemzés fizetős; a csomagok hamarosan elérhetők.</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ export interface Me {
|
|||||||
providers: string[];
|
providers: string[];
|
||||||
primary_chart_id: string | null;
|
primary_chart_id: string | null;
|
||||||
analyses_left: UnitBalance;
|
analyses_left: UnitBalance;
|
||||||
|
birth_change: BirthChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Limit on changing the own birth data (the notice text comes from the backend). */
|
||||||
|
export interface BirthChange {
|
||||||
|
limited: boolean;
|
||||||
|
next_change_at: string | null;
|
||||||
|
notice: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Detailed analyses left, per kind. */
|
/** Detailed analyses left, per kind. */
|
||||||
@@ -32,6 +40,7 @@ export interface PublicConfig {
|
|||||||
summary_model: string;
|
summary_model: string;
|
||||||
password_login: boolean;
|
password_login: boolean;
|
||||||
password_min_length: number;
|
password_min_length: number;
|
||||||
|
mock_payments: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Position {
|
export interface Position {
|
||||||
|
|||||||
Reference in New Issue
Block a user