Author SHA1 Message Date
sagifer bf7fb937d2 Merge pull request 'Worker tests: set the chart kind (charts_primary_is_own)' (#5) from main into prod
CI / test (push) Successful in 44s
CI / build (push) Successful in 13s
CI / deploy (push) Successful in 38s
Reviewed-on: #5
2026-11-17 13:25:02 +01:00
fecoandClaude Opus 5.5 0ba80abb47 Worker tests: set the chart kind (charts_primary_is_own)
CI / test (push) Successful in 44s
CI / build (push) Successful in 4m13s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 12:22:55 +00:00
sagifer a8ce5490c8 Merge pull request 'Main' (#4) from main into prod
CI / test (push) Failing after 43s
CI / build (push) Skipped
CI / deploy (push) Skipped
Reviewed-on: #4
2026-11-17 13:15:24 +01:00
fecoandClaude Opus 5.5 ae9b1b31a9 Deploy: reload Caddy so Caddyfile changes take effect
CI / test (push) Failing after 40s
CI / build (push) Skipped
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 11:55:27 +00:00
fecoandClaude Opus 5.5 786696bb1e Privacy policy page (public), data export and account deletion in the profile
CI / test (push) Failing after 42s
CI / build (push) Skipped
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 11:55:08 +00:00
fecoandClaude Opus 5.5 0791998c13 Own chart back on the Képletem menu; persons get their own menu, page and a tile
CI / test (push) Failing after 41s
CI / build (push) Skipped
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 11:20:26 +00:00
fecoandClaude Opus 5.5 fef1605848 Persons: other people's charts with package slots, list page, switcher
CI / test (push) Failing after 43s
CI / build (push) Skipped
CI / deploy (push) Skipped
- charts.kind own/person; a new person uses a 'person' unit (not refunded
  on delete); person packages and an unlimited entitlement; admins unlimited
- a person's birth data can be corrected within an hour (admins any time)
- /kepletek list with tiles, /kepletek/uj, correction page, mock person
  packages, chart page title switches between charts keeping the tab

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 11:03:55 +00:00
fecoandClaude Opus 5.5 50875c0006 Tabs scroll below the sticky header
CI / test (push) Successful in 39s
CI / build (push) Successful in 3m38s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 10:43:39 +00:00
fecoandClaude Opus 5.5 0e01f88f31 Summary card links to the detailed analysis tab
CI / test (push) Successful in 47s
CI / build (push) Successful in 3m41s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 10:43:03 +00:00
fecoandClaude Opus 5.5 1e95459671 Roomier detailed analysis offer (flex gaps were lost when it moved into a tab)
CI / test (push) Successful in 40s
CI / build (push) Successful in 3m39s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 10:37:37 +00:00
fecoandClaude Opus 5.5 afa113ceca Chart page tabs (analysis, planets, matrix, details); square aspect matrix
CI / test (push) Successful in 40s
CI / build (push) Successful in 3m36s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 10:32:10 +00:00
sagifer b0b0347b04 Merge pull request 'Main' (#3) from main into prod
CI / test (push) Successful in 39s
CI / build (push) Successful in 39s
CI / deploy (push) Successful in 42s
Reviewed-on: #3
2026-11-17 11:24:13 +01:00
fecoandClaude Opus 5.5 d2a24ca42d Chart page: Sun, Moon and ASC in one small tile, columns of equal height, wider analysis
CI / test (push) Successful in 40s
CI / build (push) Successful in 3m39s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 10:21:20 +00:00
fecoandClaude Opus 5.5 7d961fd70b Aspect grid: row and column headers, so both points of a cell are visible
CI / test (push) Successful in 40s
CI / build (push) Successful in 3m39s
CI / deploy (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-17 09:58:21 +00:00
40 changed files with 1650 additions and 171 deletions
+1
View File
@@ -134,6 +134,7 @@ jobs:
ssh "$HOST" "cd '$DIR' && \
(grep -q '^TAG=' .env && sed -i 's/^TAG=.*/TAG=$tag/' .env || echo 'TAG=$tag' >> .env) && \
docker compose pull -q && docker compose up -d --remove-orphans --wait && \
docker compose exec -T caddy caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile && \
docker image prune -f >/dev/null"
# A release (and its tag, e.g. v2026.11.17-163612e) for every deployment,
# listing the commits since the previous one.
+30
View File
@@ -0,0 +1,30 @@
-- Charts of other people ("persons": name and birth data, with their own
-- chart and analyses) next to the user's own chart.
--
-- kind 'own': the user's own chart, the current one (is_primary) and the
-- earlier ones replaced by a correction (kept for their analyses, not listed).
-- kind 'person': someone else. Each new person uses one 'person' unit of the
-- user's package (deleting does not give it back); unlimited packages and
-- admins have no limit.
ALTER TABLE charts ADD COLUMN kind text NOT NULL DEFAULT 'person' CHECK (kind IN ('own', 'person'));
UPDATE charts SET kind = 'own'
WHERE is_primary OR id IN (SELECT chart_id FROM birth_data_changes WHERE chart_id IS NOT NULL);
ALTER TABLE charts ADD CONSTRAINT charts_primary_is_own CHECK (NOT is_primary OR kind = 'own');
ALTER TABLE credit_ledger DROP CONSTRAINT credit_ledger_unit_check;
ALTER TABLE credit_ledger ADD CONSTRAINT credit_ledger_unit_check CHECK (unit IN ('natal', 'synastry', 'person'));
ALTER TABLE credit_ledger DROP CONSTRAINT credit_ledger_reason_check;
ALTER TABLE credit_ledger ADD CONSTRAINT credit_ledger_reason_check
CHECK (reason IN ('monthly_grant', 'analysis', 'chat', 'refund', 'admin_adjust', 'purchase', 'person'));
ALTER TABLE credit_ledger ADD COLUMN chart_id uuid REFERENCES charts (id) ON DELETE SET NULL;
-- Lasting rights from a package, e.g. any number of persons.
CREATE TABLE entitlements (
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
entitlement text NOT NULL CHECK (entitlement IN ('unlimited_persons')),
note text,
created_by uuid REFERENCES users (id) ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (user_id, entitlement)
);
+3 -1
View File
@@ -12,7 +12,9 @@
{$DOMAIN} {
# Temporary gate until launch (user sf, password sf). Remove this block to open the site.
basic_auth {
# The privacy policy stays public (Google's OAuth consent screen links to it).
@gated not path /adatvedelem /_next/static/* /favicon.ico /icon*
basic_auth @gated {
sf $2a$14$oggzzuNO41uGS5M.TCMlB.bQ6fdXUHtNLx9XahWyKLHjRlpEP1XN6
}
encode zstd gzip
+2
View File
@@ -87,6 +87,8 @@ services:
PASSWORD_LOGIN: ${PASSWORD_LOGIN:-false}
# Stand-in payment (adds an analysis unit at once) until Stripe is connected.
MOCK_PAYMENTS: ${MOCK_PAYMENTS:-true}
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
PERSON_PACK_SIZE: ${PERSON_PACK_SIZE:-5}
depends_on:
postgres:
condition: service_healthy
+2
View File
@@ -55,6 +55,8 @@ services:
PASSWORD_LOGIN: ${PASSWORD_LOGIN:-false}
# Stand-in payment (adds an analysis unit at once) until Stripe is connected.
MOCK_PAYMENTS: ${MOCK_PAYMENTS:-true}
FREE_PERSON_SLOTS: ${FREE_PERSON_SLOTS:-0}
PERSON_PACK_SIZE: ${PERSON_PACK_SIZE:-5}
depends_on:
postgres:
condition: service_healthy
+6 -3
View File
@@ -14,14 +14,16 @@ 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 |
| `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 |
| `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`) |
| `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 (`{"unit": "natal"}`) vagy személycsomagot (`{"package": "persons"}` / `"persons_unlimited"`); a compose-fájlokban egyelőre `true` |
| `FREE_PERSON_SLOTS` | `0` | ennyi személyt vehet fel csomag nélkül egy felhasználó |
| `PERSON_PACK_SIZE` | `5` | ennyi személy van egy személycsomagban |
| `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) |
| `SUPPORTED_LOCALES` | `hu,en` | felület- és elemzésnyelvek; az első az alapértelmezett |
| `ANALYSIS_MODEL` | `anthropic/claude-opus-5.5` | ez írja a fizetős részletes elemzéseket |
| `SUMMARY_MODEL` | `anthropic/claude-sonnet-5.5` | ez írja minden mentett képlet ingyenes rövid összefoglalóját (kb. 1 cent darabonként) |
| `ANALYSIS_PROMPT_VERSION` | `v2` | a prompt verziója (az elemzés-gyorsítótár kulcsának része) |
| `MAX_CHARTS_PER_USER` | `50` | ennyi képletet menthet egy felhasználó |
| `MAX_CHARTS_PER_USER` | `1000` | biztonsági felső korlát a képletek számára (a korlátlan csomagra is) |
| `BIND_ADDR`, `LOG_FORMAT`, `RUST_LOG` | `0.0.0.0:8081`, `text`, `info` | |
## Belépés és jogosultság
@@ -116,4 +118,5 @@ A [worker](../worker/README.md) kiküldi az e-maileket, megírja az elemzéseket
## 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).
- **Személyek** (más emberek képletei, `charts.kind = 'person'`): minden új személy egy `person` egységet használ (`credit_ledger`, `reason = 'person'`); a törlés nem adja vissza. Egységet a személycsomag ad (`PERSON_PACK_SIZE` darab), a korlátlan csomag az `entitlements` tábla `unlimited_persons` sora. Ha elfogyott, 409 `person_limit_reached`. Egy személy születési adatai a felvétel után egy órán belül javíthatók (`PATCH /v1/charts/{id}` `birth` mezővel), utána 409 `person_locked`; részletes elemzés vagy szinasztria után sem. A `/v1/me` `persons` mezője: `used`, `limit`, `left`, `unlimited`.
- **Admin:** nincs módosítási korlát, korlátlan személy, a személyek adatai bármikor javíthatók, és a részletes elemzés ingyenes (nem fogy egység).
+10 -2
View File
@@ -45,8 +45,12 @@ pub struct Config {
pub summary_model: String,
/// `ANALYSIS_PROMPT_VERSION` (default `v2`); part of the analysis cache key.
pub prompt_version: String,
/// `MAX_CHARTS_PER_USER` (default 50).
/// `MAX_CHARTS_PER_USER` (default 1000): a safety cap, also for unlimited packages.
pub max_charts_per_user: i64,
/// `FREE_PERSON_SLOTS` (default 0): persons a user may add without a package.
pub free_person_slots: i64,
/// `PERSON_PACK_SIZE` (default 5): persons in one person package.
pub person_pack_size: i64,
}
fn var(name: &str) -> Option<String> {
@@ -99,7 +103,9 @@ impl Config {
analysis_model: var("ANALYSIS_MODEL").unwrap_or_else(|| "anthropic/claude-opus-5.5".into()),
summary_model: var("SUMMARY_MODEL").unwrap_or_else(|| "anthropic/claude-sonnet-5.5".into()),
prompt_version: var("ANALYSIS_PROMPT_VERSION").unwrap_or_else(|| "v2".into()),
max_charts_per_user: parsed("MAX_CHARTS_PER_USER", 50)?,
max_charts_per_user: parsed("MAX_CHARTS_PER_USER", 1000)?,
free_person_slots: parsed("FREE_PERSON_SLOTS", 0)?,
person_pack_size: parsed("PERSON_PACK_SIZE", 5)?,
};
if config.session_ttl_days < 1 {
bail!("SESSION_TTL_DAYS must be at least 1");
@@ -128,6 +134,8 @@ impl Config {
summary_model: "anthropic/claude-summary".into(),
prompt_version: "v1".into(),
max_charts_per_user: 50,
free_person_slots: 5,
person_pack_size: 5,
}
}
}
+10 -3
View File
@@ -14,6 +14,8 @@ use crate::error::ApiError;
pub enum Unit {
Natal,
Synastry,
/// A slot for adding a person (see [`crate::persons`]).
Person,
}
impl Unit {
@@ -21,6 +23,7 @@ impl Unit {
match self {
Unit::Natal => "natal",
Unit::Synastry => "synastry",
Unit::Person => "person",
}
}
}
@@ -30,6 +33,8 @@ impl Unit {
pub struct Balance {
pub natal: i64,
pub synastry: i64,
/// Bought person slots (not the slots left; see [`crate::persons::slots`]).
pub person: i64,
}
impl Balance {
@@ -37,6 +42,7 @@ impl Balance {
match unit {
Unit::Natal => self.natal,
Unit::Synastry => self.synastry,
Unit::Person => self.person,
}
}
@@ -46,15 +52,16 @@ impl Balance {
}
pub async fn balance(conn: &mut PgConnection, user_id: Uuid) -> Result<Balance, ApiError> {
let (natal, synastry): (i64, i64) = sqlx::query_as(
let (natal, synastry, person): (i64, i64, i64) = sqlx::query_as(
"SELECT COALESCE(SUM(delta) FILTER (WHERE unit = 'natal'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'synastry'), 0)::bigint \
COALESCE(SUM(delta) FILTER (WHERE unit = 'synastry'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'person' AND reason <> 'person'), 0)::bigint \
FROM credit_ledger WHERE user_id = $1",
)
.bind(user_id)
.fetch_one(conn)
.await?;
Ok(Balance { natal, synastry })
Ok(Balance { natal, synastry, person })
}
/// Spends one unit inside the caller's transaction. The user row is locked
+1
View File
@@ -13,6 +13,7 @@ mod config;
mod credits;
mod error;
mod google;
mod persons;
mod routes;
#[cfg(test)]
mod tests;
+91
View File
@@ -0,0 +1,91 @@
//! Persons: charts of other people (name and birth data) a user adds next to
//! their own. Each new person uses one `person` unit, bought in packages;
//! deleting a person does not give it back. An unlimited package
//! (`unlimited_persons` entitlement) and admins have no limit.
//!
//! A person's birth data can be corrected within an hour of adding them,
//! then it is locked (admins: any time).
use serde_json::{Value, json};
use sqlx::PgConnection;
use time::{Duration, OffsetDateTime};
use uuid::Uuid;
use crate::auth::AuthUser;
use crate::error::ApiError;
use db::Role;
/// How long after adding a person their birth data can be corrected.
pub const EDIT_WINDOW: Duration = Duration::hours(1);
pub const LIMIT_MESSAGE: &str = "Elérted a felvehető személyek számát. További személyekhez bővítsd a csomagodat.";
pub const LOCKED_MESSAGE: &str = "A személy születési adatai csak a felvételt követő egy órán belül javíthatók.";
/// A user's person slots.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Slots {
/// Persons added so far (deleted ones included).
pub used: i64,
/// Free slots plus the bought (or granted) ones.
pub granted: i64,
pub unlimited: bool,
}
impl Slots {
/// Slots left; `None`: no limit.
pub fn left(self) -> Option<i64> {
(!self.unlimited).then(|| (self.granted - self.used).max(0))
}
pub fn view(self) -> Value {
json!({
"used": self.used,
"limit": (!self.unlimited).then_some(self.granted),
"left": self.left(),
"unlimited": self.unlimited,
})
}
}
pub async fn slots(conn: &mut PgConnection, auth: &AuthUser, free: i64) -> Result<Slots, ApiError> {
let (used, bought, entitled): (i64, i64, bool) = sqlx::query_as(
"SELECT \
(SELECT COUNT(*) FROM credit_ledger WHERE user_id = $1 AND unit = 'person' AND reason = 'person'), \
(SELECT COALESCE(SUM(delta), 0)::bigint FROM credit_ledger \
WHERE user_id = $1 AND unit = 'person' AND reason <> 'person'), \
EXISTS (SELECT 1 FROM entitlements WHERE user_id = $1 AND entitlement = 'unlimited_persons')",
)
.bind(auth.id())
.fetch_one(conn)
.await?;
Ok(Slots { used, granted: free + bought, unlimited: entitled || auth.user.has_role(Role::Admin) })
}
/// Fails when no slot is left (a quick check before calculating a chart).
pub async fn check(conn: &mut PgConnection, auth: &AuthUser, free: i64) -> Result<(), ApiError> {
if slots(conn, auth, free).await?.left() == Some(0) {
return Err(ApiError::conflict("person_limit_reached", LIMIT_MESSAGE));
}
Ok(())
}
/// Uses a slot for the new person `chart_id`, inside the transaction that
/// saves it. The user row is locked, so parallel saves cannot overspend.
pub async fn spend(tx: &mut PgConnection, auth: &AuthUser, free: i64, chart_id: Uuid) -> Result<(), ApiError> {
sqlx::query("SELECT id FROM users WHERE id = $1 FOR UPDATE").bind(auth.id()).execute(&mut *tx).await?;
check(tx, auth, free).await?;
sqlx::query(
"INSERT INTO credit_ledger (id, user_id, unit, delta, reason, chart_id) VALUES ($1, $2, 'person', -1, 'person', $3)",
)
.bind(Uuid::now_v7())
.bind(auth.id())
.bind(chart_id)
.execute(tx)
.await?;
Ok(())
}
/// Whether the birth data of a person added at `created_at` can still be corrected.
pub fn editable(auth: &AuthUser, created_at: OffsetDateTime, now: OffsetDateTime) -> bool {
auth.user.has_role(Role::Admin) || now - created_at < EDIT_WINDOW
}
+2
View File
@@ -31,12 +31,14 @@ pub async fn me(State(state): St, auth: AuthUser) -> ApiResult<Json<Value>> {
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?;
let persons = crate::persons::slots(&mut conn, &auth, state.config.free_person_slots).await?;
Ok(Json(json!({
"user": UserView::from(&auth.user),
"providers": providers.into_iter().map(|(p,)| p).collect::<Vec<_>>(),
"primary_chart_id": primary.map(|(id,)| id),
"analyses_left": balance.view(),
"birth_change": birth_change,
"persons": persons.view(),
})))
}
+98 -10
View File
@@ -1,5 +1,6 @@
//! Natal charts of a user: their own (primary) chart and charts of others
//! they entered (partner, family). Calculated by the horoscope service.
//! Natal charts of a user: their own chart (kind `own`; the current one is
//! primary) and charts of other people they added (kind `person`, see
//! [`crate::persons`]). Calculated by the horoscope service.
use axum::Json;
use axum::extract::State;
@@ -16,6 +17,7 @@ use crate::AppState;
use crate::auth::AuthUser;
use crate::birth_changes;
use crate::error::{ApiError, ApiResult};
use crate::persons;
use crate::views::{chart_hash, chart_highlights, rfc3339};
#[derive(Debug, Clone, sqlx::FromRow)]
@@ -24,6 +26,8 @@ pub struct ChartRow {
pub owner_id: Uuid,
pub label: String,
pub is_primary: bool,
/// `own` or `person`.
pub kind: String,
pub birth_data: Value,
pub result: Value,
pub chart_hash: String,
@@ -31,7 +35,8 @@ pub struct ChartRow {
pub updated_at: OffsetDateTime,
}
const CHART_COLUMNS: &str = "id, owner_id, label, is_primary, birth_data, result, chart_hash, created_at, updated_at";
const CHART_COLUMNS: &str =
"id, owner_id, label, is_primary, kind, birth_data, result, chart_hash, created_at, updated_at";
impl ChartRow {
/// Full view for the owner.
@@ -40,6 +45,8 @@ impl ChartRow {
"id": self.id,
"label": self.label,
"is_primary": self.is_primary,
"kind": self.kind,
"editable_until": self.editable_until().map(rfc3339),
"birth_data": self.birth_data,
"highlights": chart_highlights(&self.result),
"chart": self.result,
@@ -49,11 +56,23 @@ impl ChartRow {
})
}
/// Until when a person's birth data can be corrected (admins: any time).
fn editable_until(&self) -> Option<OffsetDateTime> {
(self.kind == "person").then(|| self.created_at + persons::EDIT_WINDOW)
}
pub fn summary_view(&self) -> Value {
json!({
"id": self.id,
"label": self.label,
"is_primary": self.is_primary,
"kind": self.kind,
"editable_until": self.editable_until().map(rfc3339),
"birth": {
"date": self.birth_data.get("date"),
"time": self.birth_data.get("time"),
"place": self.result.pointer("/location/place/name"),
},
"highlights": chart_highlights(&self.result),
"created_at": rfc3339(self.created_at),
})
@@ -140,9 +159,12 @@ pub async fn create(
) -> ApiResult<(StatusCode, Json<Value>)> {
let label = clean_label(&req.label)?;
let birth = clean_birth(req.birth)?;
let existing: Option<ChartRow> =
sqlx::query_as(&format!("SELECT {CHART_COLUMNS} FROM charts WHERE owner_id = $1 AND birth_data = $2 LIMIT 1"))
let kind = if req.is_primary { "own" } else { "person" };
let existing: Option<ChartRow> = sqlx::query_as(&format!(
"SELECT {CHART_COLUMNS} FROM charts WHERE owner_id = $1 AND kind = $2 AND birth_data = $3 LIMIT 1"
))
.bind(auth.id())
.bind(kind)
.bind(&birth)
.fetch_optional(&state.db)
.await?;
@@ -175,6 +197,10 @@ pub async fn create(
format!("at most {} charts can be saved", state.config.max_charts_per_user),
));
}
let free = state.config.free_person_slots;
if kind == "person" {
persons::check(&mut *state.db.acquire().await?, &auth, free).await?;
}
let (birth, result, hash) = calculate(&state, birth).await?;
let mut tx = state.db.begin().await?;
@@ -185,13 +211,14 @@ pub async fn create(
.await?;
}
let row: ChartRow = sqlx::query_as(&format!(
"INSERT INTO charts (id, owner_id, label, is_primary, birth_data, result, chart_hash) \
VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING {CHART_COLUMNS}"
"INSERT INTO charts (id, owner_id, label, is_primary, kind, birth_data, result, chart_hash) \
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING {CHART_COLUMNS}"
))
.bind(Uuid::now_v7())
.bind(auth.id())
.bind(label)
.bind(req.is_primary)
.bind(kind)
.bind(birth)
.bind(result)
.bind(hash)
@@ -199,6 +226,8 @@ pub async fn create(
.await?;
if req.is_primary {
birth_changes::record(&mut tx, &auth, row.id).await?;
} else {
persons::spend(&mut tx, &auth, free, row.id).await?;
}
tx.commit().await?;
queue_summary(&state, &auth, &row).await;
@@ -218,10 +247,14 @@ pub async fn get_one(
pub struct UpdateChart {
label: Option<String>,
is_primary: Option<bool>,
/// Corrected birth data of a person, within an hour of adding them
/// (admins: any time). The user's own data is changed by saving a new
/// own chart instead (analyses belong to the old one).
birth: Option<Value>,
}
/// Renames the chart or changes which chart is the user's own. Birth data is
/// not editable: a corrected chart is a new chart (analyses belong to the old one).
/// Renames the chart, changes which chart is the user's own (a person made
/// primary becomes `own`) or corrects a person's birth data.
pub async fn update(
State(state): St,
auth: AuthUser,
@@ -234,7 +267,22 @@ pub async fn update(
None => chart.label.clone(),
};
let is_primary = req.is_primary.unwrap_or(chart.is_primary);
let recalculated = match req.birth {
Some(birth) => Some(corrected_birth(&state, &auth, &chart, birth).await?),
None => None,
};
let mut tx = state.db.begin().await?;
if let Some((birth, result, hash)) = &recalculated {
// The old summary (and an admin's analyses) no longer match the chart.
sqlx::query("DELETE FROM analyses WHERE chart_id = $1").bind(id).execute(&mut *tx).await?;
sqlx::query("UPDATE charts SET birth_data = $1, result = $2, chart_hash = $3 WHERE id = $4")
.bind(birth)
.bind(result)
.bind(hash)
.bind(id)
.execute(&mut *tx)
.await?;
}
if is_primary && !chart.is_primary {
sqlx::query("UPDATE charts SET is_primary = false, updated_at = now() WHERE owner_id = $1 AND is_primary")
.bind(auth.id())
@@ -242,7 +290,8 @@ pub async fn update(
.await?;
}
let row: ChartRow = sqlx::query_as(&format!(
"UPDATE charts SET label = $1, is_primary = $2, updated_at = now() WHERE id = $3 RETURNING {CHART_COLUMNS}"
"UPDATE charts SET label = $1, is_primary = $2, kind = CASE WHEN $2 THEN 'own' ELSE kind END, \
updated_at = now() WHERE id = $3 RETURNING {CHART_COLUMNS}"
))
.bind(label)
.bind(is_primary)
@@ -253,9 +302,48 @@ pub async fn update(
birth_changes::record(&mut tx, &auth, id).await?;
}
tx.commit().await?;
if recalculated.is_some() {
queue_summary(&state, &auth, &row).await;
}
Ok(Json(row.owner_view()))
}
/// Checks that a person's birth data may still be corrected and calculates the new chart.
async fn corrected_birth(
state: &AppState,
auth: &AuthUser,
chart: &ChartRow,
birth: Value,
) -> Result<(Value, Value, String), ApiError> {
if chart.kind != "person" {
return Err(ApiError::BadRequest("the own birth data is changed by saving a new own chart".into()));
}
if !persons::editable(auth, chart.created_at, OffsetDateTime::now_utc()) {
return Err(ApiError::conflict("person_locked", persons::LOCKED_MESSAGE));
}
let admin = auth.user.has_role(db::Role::Admin);
let (analysed, in_synastry): (bool, bool) = sqlx::query_as(
"SELECT EXISTS (SELECT 1 FROM analyses WHERE chart_id = $1 AND kind <> 'summary' AND status <> 'failed'), \
EXISTS (SELECT 1 FROM synastries WHERE chart1_id = $1 OR chart2_id = $1)",
)
.bind(chart.id)
.fetch_one(&state.db)
.await?;
if analysed && !admin {
return Err(ApiError::conflict(
"person_analysed",
"Ehhez a személyhez már készült részletes elemzés, ezért az adatai nem módosíthatók.",
));
}
if in_synastry {
return Err(ApiError::conflict(
"person_in_synastry",
"A személy szerepel egy összevetésben, ezért az adatai nem módosíthatók.",
));
}
calculate(state, birth).await
}
/// Deletes the chart with its synastries, analyses and shares.
pub async fn remove(
State(state): St,
+1
View File
@@ -122,6 +122,7 @@ async fn public_config(State(state): St) -> Json<Value> {
"summary_model": c.summary_model,
"password_login": c.password_login,
"mock_payments": c.mock_payments,
"person_pack_size": c.person_pack_size,
"password_min_length": crate::auth::MIN_PASSWORD_LEN,
}))
}
+41 -7
View File
@@ -1,6 +1,6 @@
//! 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.
//! stand-in: "paying" grants what was bought right away (an analysis unit or
//! a person package), so the paid flow can be used end to end.
use axum::Json;
use axum::extract::State;
@@ -13,14 +13,26 @@ use super::{Body, St};
use crate::auth::AuthUser;
use crate::credits::{self, Unit};
use crate::error::{ApiError, ApiResult};
use crate::persons;
#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct MockPayment {
unit: Unit,
/// One analysis unit.
unit: Option<Unit>,
package: Option<Package>,
}
/// Adds one unit of the given kind as a (pretend) purchase.
#[derive(Debug, Clone, Copy, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum Package {
/// `PERSON_PACK_SIZE` more persons.
Persons,
/// Any number of persons.
PersonsUnlimited,
}
/// Grants an analysis unit or a person package as a (pretend) purchase.
pub async fn mock(
State(state): St,
auth: AuthUser,
@@ -29,16 +41,38 @@ pub async fn mock(
if !state.config.mock_payments {
return Err(ApiError::NotFound("payment method"));
}
let (unit, delta) = match (req.unit, req.package) {
(Some(unit), None) => (Some(unit), 1),
(None, Some(Package::Persons)) => (Some(Unit::Person), state.config.person_pack_size),
(None, Some(Package::PersonsUnlimited)) => (None, 0),
_ => return Err(ApiError::BadRequest("give either unit or package".into())),
};
let mut tx = state.db.begin().await?;
match unit {
Some(unit) => {
sqlx::query(
"INSERT INTO credit_ledger (id, user_id, unit, delta, reason, note) VALUES ($1, $2, $3, 1, 'purchase', 'mock payment')",
"INSERT INTO credit_ledger (id, user_id, unit, delta, reason, note) \
VALUES ($1, $2, $3, $4, 'purchase', 'mock payment')",
)
.bind(Uuid::now_v7())
.bind(auth.id())
.bind(req.unit.as_str())
.bind(unit.as_str())
.bind(delta as i32)
.execute(&mut *tx)
.await?;
}
None => {
sqlx::query(
"INSERT INTO entitlements (user_id, entitlement, note) VALUES ($1, 'unlimited_persons', 'mock payment') \
ON CONFLICT DO NOTHING",
)
.bind(auth.id())
.execute(&mut *tx)
.await?;
}
}
let balance = credits::balance(&mut tx, auth.id()).await?;
let persons = persons::slots(&mut tx, &auth, state.config.free_person_slots).await?;
tx.commit().await?;
Ok(Json(json!({ "analyses_left": balance.view() })))
Ok(Json(json!({ "analyses_left": balance.view(), "persons": persons.view() })))
}
+75
View File
@@ -752,3 +752,78 @@ async fn admins_get_free_analyses_and_mock_payments_add_units(pool: PgPool) {
let r = app.post("/v1/payments/mock", Some(&anna), json!({"unit": "natal"})).await;
assert_eq!(r.status, StatusCode::NOT_FOUND);
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn persons_use_package_slots(pool: PgPool) {
let app = TestApp::with_config(pool, |c| {
c.free_person_slots = 1;
c.person_pack_size = 2;
})
.await;
let anna = app.register("anna@example.com", "Anna").await;
let own = app.chart(&anna, "Saját", true, "1990-03-15").await;
assert_eq!(own["kind"], "own");
let persons = |me: Value| me["persons"].clone();
assert_eq!(
persons(app.get("/v1/me", Some(&anna)).await.body),
json!({"used": 0, "limit": 1, "left": 1, "unlimited": false})
);
// the free slot, then the limit; deleting does not give the slot back
let first = app.chart(&anna, "Béla", false, "1985-08-02").await;
assert_eq!((&first["kind"], first["editable_until"].is_string()), (&json!("person"), true));
let new_person = |date: &str| json!({"label": "Cili", "birth": {"date": date, "time": "14:30", "country": "HU", "place": "Szeged"}});
let r = app.post("/v1/charts", Some(&anna), new_person("1986-01-01")).await;
assert_eq!((r.status, r.body["error"]["code"].as_str()), (StatusCode::CONFLICT, Some("person_limit_reached")));
assert_eq!(r.body["error"]["message"], crate::persons::LIMIT_MESSAGE);
let r = app.call("DELETE", &format!("/v1/charts/{}", first["id"].as_str().unwrap()), Some(&anna), None).await;
assert_eq!(r.status, StatusCode::NO_CONTENT);
assert_eq!(persons(app.get("/v1/me", Some(&anna)).await.body)["left"], 0);
// a package adds two slots
let r = app.post("/v1/payments/mock", Some(&anna), json!({"package": "persons"})).await;
assert_eq!(r.body["persons"], json!({"used": 1, "limit": 3, "left": 2, "unlimited": false}), "{}", r.body);
let second = app.chart(&anna, "Cili", false, "1986-01-01").await;
app.chart(&anna, "Dani", false, "1987-01-01").await;
let r = app.post("/v1/charts", Some(&anna), new_person("1988-01-01")).await;
assert_eq!(r.status, StatusCode::CONFLICT);
// the unlimited package
let r = app.post("/v1/payments/mock", Some(&anna), json!({"package": "persons_unlimited"})).await;
assert_eq!(r.body["persons"], json!({"used": 3, "limit": null, "left": null, "unlimited": true}));
app.chart(&anna, "Emma", false, "1988-01-01").await;
let list = app.get("/v1/charts", Some(&anna)).await.body;
let kinds: Vec<&str> = list["charts"].as_array().unwrap().iter().map(|c| c["kind"].as_str().unwrap()).collect();
assert_eq!(kinds, ["own", "person", "person", "person"]);
assert_eq!(list["charts"][1]["birth"]["date"], "1988-01-01");
// a person's birth data can be corrected within an hour, then it is locked
let id = second["id"].as_str().unwrap();
let corrected = json!({"birth": {"date": "1986-01-02", "time": "10:00", "country": "HU", "place": "Szeged"}});
let r = app.call("PATCH", &format!("/v1/charts/{id}"), Some(&anna), Some(corrected.clone())).await;
assert_eq!((r.status, &r.body["birth_data"]["date"]), (StatusCode::OK, &json!("1986-01-02")), "{}", r.body);
sqlx::query("UPDATE charts SET created_at = now() - interval '2 hours' WHERE id = $1::uuid")
.bind(id)
.execute(&app.pool)
.await
.unwrap();
let r = app.call("PATCH", &format!("/v1/charts/{id}"), Some(&anna), Some(corrected.clone())).await;
assert_eq!((r.status, r.body["error"]["code"].as_str()), (StatusCode::CONFLICT, Some("person_locked")));
let r =
app.call("PATCH", &format!("/v1/charts/{}", own["id"].as_str().unwrap()), Some(&anna), Some(corrected)).await;
assert_eq!(r.status, StatusCode::BAD_REQUEST);
// admins: no limit, corrections any time
let admin = app.register("admin@example.com", "Admin").await;
assert_eq!(persons(app.get("/v1/me", Some(&admin)).await.body)["unlimited"], true);
let p = app.chart(&admin, "Feri", false, "1970-01-01").await;
let pid = p["id"].as_str().unwrap();
sqlx::query("UPDATE charts SET created_at = now() - interval '2 days' WHERE id = $1::uuid")
.bind(pid)
.execute(&app.pool)
.await
.unwrap();
let corrected = json!({"birth": {"date": "1970-01-02", "time": "10:00", "country": "HU", "place": "Szeged"}});
let r = app.call("PATCH", &format!("/v1/charts/{pid}"), Some(&admin), Some(corrected)).await;
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
}
@@ -0,0 +1,199 @@
import type { Metadata } from "next";
import Link from "next/link";
import { Logo } from "@/components/SiteHeader";
import { OPERATOR, PRIVACY_UPDATED } from "@/lib/legal";
import { getMe } from "@/lib/server";
export const metadata: Metadata = {
title: "Adatvédelmi tájékoztató",
description: "Hogyan kezeli a Sorsfonalak a személyes adataidat.",
};
/** Privacy policy: public, also for visitors who are not logged in. */
export default async function PrivacyPage() {
const me = await getMe();
return (
<>
{!me && (
<header className="site-header">
<Logo />
</header>
)}
<main className="page legal">
<div className="page-head">
<h1>Adatvédelmi tájékoztató</h1>
<p className="muted">Hatályos: {PRIVACY_UPDATED}</p>
</div>
<section>
<h2>1. Ki kezeli az adataidat?</h2>
<p>
A Sorsfonalak szolgáltatás (sorsfonalak.hu) adatkezelője: <strong>{OPERATOR.name}</strong>, {OPERATOR.address}
{OPERATOR.registration ? `, ${OPERATOR.registration}` : ""}. Adatvédelmi kérdésekben itt érsz el minket:{" "}
<strong>{OPERATOR.email}</strong>.
</p>
</section>
<section>
<h2>2. Milyen adatokat kezelünk, és miért?</h2>
<table className="legal-table">
<thead>
<tr>
<th scope="col">Adat</th>
<th scope="col">Cél</th>
<th scope="col">Jogalap</th>
</tr>
</thead>
<tbody>
<tr>
<td>Google-fiókod neve, e-mail-címe és azonosítója (belépéskor a Google adja át)</td>
<td>Fiókod létrehozása, belépés, kapcsolattartás</td>
<td>Szerződés teljesítése (GDPR 6. cikk (1) b)</td>
</tr>
<tr>
<td>Megjelenített név, az elemzések nyelve</td>
<td>A szolgáltatás személyre szabása</td>
<td>Szerződés teljesítése</td>
</tr>
<tr>
<td>Születési adataid: dátum, időpont, hely</td>
<td>A születési képleted kiszámítása és az elemzések elkészítése</td>
<td>Szerződés teljesítése</td>
</tr>
<tr>
<td>Az általad felvett személyek neve és születési adatai</td>
<td>Az ő képletük és elemzésük elkészítése a kérésedre</td>
<td>Szerződés teljesítése; a felvételhez az érintett beleegyezése szükséges (lásd 4. pont)</td>
</tr>
<tr>
<td>A képletek és az elkészült elemzések</td>
<td>Hogy bármikor újra megnézhesd őket</td>
<td>Szerződés teljesítése</td>
</tr>
<tr>
<td>Vásárlásaid és felhasznált kereteid (elemzések, személyek)</td>
<td>A megvásárolt szolgáltatás nyújtása, elszámolás</td>
<td>Szerződés teljesítése; számviteli kötelezettség (6. cikk (1) c)</td>
</tr>
<tr>
<td>IP-cím, böngésző adatai, a kérések ideje (szervernaplók)</td>
<td>Biztonság, hibakeresés, visszaélések kiszűrése</td>
<td>Jogos érdek (6. cikk (1) f)</td>
</tr>
</tbody>
</table>
<p>
Bankkártyaadatot nem kezelünk és nem tárolunk; a fizetést, amikor elindul, külső fizetési szolgáltató
végzi, akinek a neve itt lesz feltüntetve.
</p>
</section>
<section>
<h2>3. Az elemzések és a mesterséges intelligencia</h2>
<p>
A rövid összefoglalót és a részletes elemzést nagy nyelvi modell (mesterséges intelligencia) írja. A
modellhez <strong>csak a képlet csillagászati adatai</strong> jutnak el (a bolygók jegye, foka, háza és
fényszögei). Nevet, e-mail-címet, születési dátumot, időpontot vagy helyet nem küldünk el. Az elemzés
szórakoztató és önismereti célú szöveg, nem minősül egészségügyi, pénzügyi, jogi vagy más szakmai
tanácsnak.
</p>
</section>
<section>
<h2>4. Más emberek adatai</h2>
<p>
Ha valaki más (például társad vagy családtagod) születési adatait veszed fel, kérjük, csak az ő
beleegyezésével tedd. Az ő adatait kizárólag te látod; tőlünk senki más nem kapja meg. Az általad felvett
személyt bármikor törölheted, ezzel a képlete és az elemzései is törlődnek.
</p>
</section>
<section>
<h2>5. Kik férnek hozzá az adatokhoz? (adatfeldolgozók)</h2>
<ul>
<li>
<strong>DigitalOcean, LLC</strong> – a szerverek üzemeltetése; az adatok az Európai Unióban (Amszterdam)
vannak tárolva.
</li>
<li>
<strong>Cloudflare, Inc.</strong> – a forgalom továbbítása és a támadások elleni védelem; az oldal
letöltésekor kezeli az IP-címedet és a kérés adatait.
</li>
<li>
<strong>Google LLC</strong> – bejelentkezés Google-fiókkal.
</li>
<li>
<strong>OpenRouter, Inc.</strong> és az általa elért modellszolgáltató (jelenleg{" "}
<strong>Anthropic PBC</strong>) – az elemzések megírása, kizárólag a 3. pontban leírt csillagászati
adatokból.
</li>
</ul>
<p>
Ezek közül néhány szolgáltató az Egyesült Államokban működik. Az adattovábbítás az EU–USA adatvédelmi
keretrendszer (Data Privacy Framework) vagy az Európai Bizottság általános szerződési feltételei
(SCC) alapján történik.
</p>
</section>
<section>
<h2>6. Meddig őrizzük az adatokat?</h2>
<ul>
<li>Fiókod adatait, képleteidet és elemzéseidet a fiókod törléséig.</li>
<li>A biztonsági mentésekből a törölt adatok legkésőbb 14 nap után tűnnek el.</li>
<li>A szervernaplókat legfeljebb 30 napig őrizzük.</li>
<li>A számlázáshoz szükséges adatokat a számviteli törvény szerinti ideig (8 évig) őrizzük.</li>
</ul>
</section>
<section>
<h2>7. Sütik</h2>
<p>
Csak egy, a működéshez feltétlenül szükséges sütit használunk (<code>sf_session</code>), amely belépve
tart. Reklám- vagy követő sütiket, illetve látogatottságmérőt nem használunk.
</p>
</section>
<section>
<h2>8. A jogaid</h2>
<ul>
<li>
<strong>Hozzáférés és adathordozhatóság:</strong> a <Link href="/profil#adataim">Profil</Link> oldalon
egy kattintással letöltheted minden adatodat.
</li>
<li>
<strong>Helyesbítés:</strong> a nevedet és a születési adataidat a Profil oldalon módosíthatod.
</li>
<li>
<strong>Törlés:</strong> a fiókodat és minden adatodat a Profil oldalon törölheted.
</li>
<li>
<strong>Korlátozás és tiltakozás:</strong> a fenti e-mail-címen kérheted.
</li>
</ul>
<p>
Kérésedre legkésőbb egy hónapon belül válaszolunk. Ha úgy érzed, megsértettük a jogaidat, panaszt tehetsz
a Nemzeti Adatvédelmi és Információszabadság Hatóságnál (NAIH, 1055 Budapest, Falk Miksa utca 9–11.,{" "}
<a href="https://naih.hu" target="_blank" rel="noopener noreferrer">
naih.hu
</a>
), vagy bírósághoz fordulhatsz.
</p>
</section>
<section>
<h2>9. Korhatár</h2>
<p>A szolgáltatást 16 éven felüliek használhatják.</p>
</section>
<section>
<h2>10. Változások</h2>
<p>
Ha a tájékoztató lényegesen változik, a belépéskor vagy e-mailben jelezzük. A mindenkori változat ezen az
oldalon olvasható.
</p>
</section>
</main>
</>
);
}
+2 -1
View File
@@ -1,4 +1,5 @@
import type { Metadata } from "next";
import Link from "next/link";
import { redirect } from "next/navigation";
import { Logo } from "@/components/SiteHeader";
@@ -63,7 +64,7 @@ export default async function LoginPage({ searchParams }: { searchParams: Promis
<p className="auth-foot">Még nincs fiókod? Az első belépéskor létrejön.</p>
<p className="hint">
A belépéssel elfogadod, hogy a születési adataidat a képleted kiszámításához tároljuk. Bármikor törölheted
őket a profilodban.
őket a profilodban. Részletek: <Link href="/adatvedelem">adatvédelmi tájékoztató</Link>.
</p>
</div>
</main>
+126 -12
View File
@@ -167,8 +167,13 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.gsi-overlay > div, .gsi-overlay iframe { transform: scale(1.06, 1.2); }
/* Detailed analysis */
.analysis-card { gap: 14px; }
.analysis { display: flex; flex-direction: column; gap: 28px; max-width: 72ch; }
.analysis-card { display: flex; flex-direction: column; gap: 16px; }
.analysis-offer { padding: 8px 0 4px; }
.analysis-offer .offer-head { display: flex; flex-direction: column; gap: 8px; }
.analysis-offer p.muted { max-width: 64ch; line-height: 1.7; }
.analysis-offer .form-actions, .analysis-offer .pay-box { margin-top: 12px; }
.analysis-offer .form-actions { gap: 12px 16px; }
.analysis { display: flex; flex-direction: column; gap: 28px; }
.analysis-head { display: flex; flex-direction: column; gap: 12px; }
.analysis-head h2 { font-size: 34px; }
.analysis-lead { font-size: 17px; line-height: 1.7; color: var(--ink-2); font-style: italic; }
@@ -186,6 +191,11 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
.summary-title { font-size: 26px; }
.summary-text { font-size: 16px; line-height: 1.65; color: var(--ink-2); }
.summary-more {
margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); width: 100%;
color: var(--gold); font-weight: 500; text-decoration: none;
}
.summary-more:hover { text-decoration: underline; text-underline-offset: 3px; }
.summary-text strong { color: var(--ink); font-weight: 600; }
.skeleton { display: flex; flex-direction: column; gap: 8px; }
.skeleton span { height: 12px; border-radius: 6px; background: var(--line); animation: pulse 1.4s ease-in-out infinite; }
@@ -205,12 +215,21 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@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-box { display: flex; flex-direction: column; gap: 16px; padding: 20px; max-width: 520px; 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-wheel-card { padding: 16px; gap: 10px; }
.chart-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); gap: 24px; align-items: stretch; }
.chart-side { gap: 16px; }
.chart-side .summary-card { flex: 1 1 auto; }
.chart-wheel-card { padding: 16px; gap: 10px; justify-content: center; }
.chart-wheel { width: 100%; height: auto; display: block; max-width: 680px; margin: 0 auto; }
.chart-layout .big3 { grid-template-columns: 1fr; }
.chart-layout .big3 {
grid-template-columns: repeat(3, 1fr); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.chart-layout .big3 > div { background: none; border: 0; border-radius: 0; padding: 14px 16px; min-width: 0; }
.chart-layout .big3 > div + div { border-left: 1px solid var(--line); }
.chart-layout .big3 .glyph { font-size: 20px; }
.chart-layout .big3 strong { font-size: 21px; }
.chart-layout .big3 .muted { font-size: 13px; }
.wheel-legend { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.wheel-legend-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
@@ -230,6 +249,11 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
}
.aspect-grid th { color: var(--ink); font-weight: 400; font-size: 17px; background: var(--panel-2); }
.aspect-grid .grid-angle { font: 600 11px var(--font-body); color: var(--gold); letter-spacing: 0.3px; }
.aspect-grid td.corner { border: 0; background: none; }
.aspect-grid td.diag { background: var(--line); }
.aspect-grid tbody td:not(.diag):hover { background: var(--panel-2); }
.grid-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink-2); }
.grid-legend .sym { font-size: 17px; }
.asp-conjunction { color: var(--gold); }
.asp-trine, .asp-sextile { color: var(--harmonic); }
.asp-square { color: var(--square); }
@@ -237,10 +261,11 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.details > summary { cursor: pointer; color: var(--gold); min-height: 44px; display: flex; align-items: center; }
.details[open] > summary { margin-bottom: 8px; }
@media (max-width: 640px) {
.aspect-grid { font-size: 13px; }
.aspect-grid td, .aspect-grid th { width: 23px; min-width: 23px; height: 23px; }
.aspect-grid th { font-size: 14px; }
.aspect-grid .grid-angle { font-size: 9px; }
.aspect-grid { font-size: 12px; }
.aspect-grid td, .aspect-grid th { width: 19px; min-width: 19px; height: 19px; }
.aspect-grid th { font-size: 13px; }
.aspect-grid .grid-angle { font-size: 8px; letter-spacing: 0; }
.chart-tabs { padding: 4px 12px 16px; }
}
.aspect-harmonic { color: var(--harmonic); }
.aspect-tense { color: var(--tense); }
@@ -275,7 +300,6 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 900px) {
.chart-layout { grid-template-columns: 1fr; }
.chart-layout .big3 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
@@ -285,8 +309,98 @@ td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.card { padding: 18px; }
.auth-aside { padding: 28px 20px; min-height: 0; }
.wheel { width: 60%; }
.big3, .chart-layout .big3 { grid-template-columns: 1fr; }
.big3 { grid-template-columns: 1fr; }
.chart-layout .big3 > div { padding: 12px 10px; }
.chart-layout .big3 strong { font-size: 18px; }
.chart-wheel-card { padding: 8px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Tabs */
.chart-tabs { padding-top: 8px; }
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab {
background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 12px 16px; min-height: 44px;
color: var(--muted); font: 500 15px var(--font-body); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.tab:focus-visible, .tab-panel:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tabs { scroll-margin-top: 88px; }
.tab-panel { padding-top: 20px; }
@media (max-width: 640px) { .tab { padding: 12px 10px; font-size: 14px; } .tabs { scroll-margin-top: 120px; } }
/* Charts list, persons */
.chart-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.chart-card {
background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column;
transition: border-color 0.15s;
}
.chart-card:hover { border-color: var(--line-2); }
.chart-card-link, .chart-card-new { display: flex; flex-direction: column; gap: 6px; padding: 20px; color: inherit; text-decoration: none; flex: 1; }
.chart-card-name { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--ink); }
.chart-card-tag { margin: 0 20px 16px; font-size: 13px; color: var(--gold); }
.chart-card-new { border-style: dashed; justify-content: center; align-items: flex-start; min-height: 150px; }
.chart-card-new:hover { border-color: var(--gold); }
.chart-card-plus { font-size: 28px; line-height: 1; color: var(--gold); }
.sign-trio { display: flex; gap: 16px; margin-top: 8px; }
.sign-trio > span { display: inline-flex; align-items: baseline; gap: 4px; }
.sign-trio .sym:first-child, .trio-ac { color: var(--muted); font-size: 14px; }
.trio-ac { font: 600 11px var(--font-body); letter-spacing: 0.3px; }
.trio-sign { color: var(--gold); font-size: 20px; }
.person-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 0 12px 12px; border-top: 1px solid var(--line); padding-top: 8px; margin: 0 8px; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(242, 160, 160, 0.08); color: var(--danger); border-color: var(--danger); }
.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pack {
display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 16px 18px;
background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius);
}
.pack strong { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.pack .btn { margin-top: 8px; }
/* Chart switcher (the chart page title) */
.switcher { position: relative; align-self: flex-start; }
.switcher h1 { margin: 0; }
.switcher-button {
font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
display: inline-flex; align-items: baseline; gap: 10px;
}
.switcher-button:hover .switcher-caret, .switcher-button[aria-expanded="true"] .switcher-caret { color: var(--gold); }
.switcher-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 4px; }
.switcher-caret { font-size: 0.55em; color: var(--muted); transition: color 0.15s; }
.switcher-menu {
position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; min-width: 280px; max-width: min(360px, calc(100vw - 32px));
background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
padding: 6px; font-family: var(--font-body);
}
.switcher-menu ul { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.switcher-menu li a {
display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 12px; min-height: 44px;
border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 15px;
}
.switcher-menu li a strong { font-weight: 500; }
.switcher-menu li a .muted { font-size: 13px; white-space: nowrap; }
.switcher-menu li a:hover { background: var(--panel-2); }
.switcher-menu li a[aria-current="page"] { background: var(--panel-2); }
.switcher-menu li a[aria-current="page"] strong { color: var(--gold); }
.switcher-foot { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 12px 6px; font-size: 14px; }
.switcher-foot a { color: var(--gold); text-decoration: none; }
.switcher-foot a:hover { text-decoration: underline; }
.persons-tile { position: relative; gap: 4px; padding: 16px 48px 16px 20px; color: inherit; text-decoration: none; transition: border-color 0.15s; }
.persons-tile:hover { border-color: var(--gold); }
.persons-tile strong { font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.persons-tile .muted { font-size: 14px; }
.persons-tile-arrow { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); color: var(--gold); font-size: 20px; }
/* Legal pages */
.legal { max-width: 820px; gap: 28px; }
.legal section { display: flex; flex-direction: column; gap: 10px; }
.legal h2 { font-size: 24px; }
.legal p, .legal li { line-height: 1.7; color: var(--ink-2); }
.legal ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.legal a { color: var(--gold); }
.legal-table td { vertical-align: top; line-height: 1.5; }
.danger-box { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--danger); border-radius: var(--radius); }
@@ -0,0 +1,29 @@
"use client";
import { useRouter } from "next/navigation";
import { BirthForm } from "@/app/profil/BirthForm";
import type { BirthData } from "@/lib/types";
export function EditPerson({
id,
name,
initial,
}: {
id: string;
name: string;
initial: BirthData & { placeName: string | null; region: string | null };
}) {
const router = useRouter();
return (
<BirthForm
initial={initial}
person={{ chartId: id, name }}
onCancel={() => router.push("/szemelyek")}
onSaved={() => {
router.push(`/kepletek/${id}`);
router.refresh();
}}
/>
);
}
@@ -0,0 +1,54 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { backendGet, requireMe } from "@/lib/server";
import type { Chart } from "@/lib/types";
import { EditPerson } from "./EditPerson";
export const metadata: Metadata = { title: "Adatok javítása" };
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
/** Correcting a person's birth data (within an hour of adding them; admins any time). */
export default async function EditPersonPage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const me = await requireMe(`/kepletek/${id}/javitas`);
if (!UUID.test(id)) notFound();
const chart = await backendGet<Chart>(`/v1/charts/${id}`);
if (!chart || chart.kind !== "person") notFound();
const editable =
me.user.roles.includes("admin") || (chart.editable_until !== null && Date.parse(chart.editable_until) > Date.now());
return (
<main className="page">
<div className="page-head">
<h1>{chart.label} adatai</h1>
<p className="muted">
A javítás után újraszámoljuk a képletet és a rövid összefoglalót.
</p>
</div>
<section className="card" aria-label="Születési adatok">
{editable ? (
<EditPerson
id={id}
name={chart.label}
initial={{
...chart.birth_data,
placeName: chart.chart.location.place?.name ?? null,
region: chart.chart.location.place?.region ?? null,
}}
/>
) : (
<>
<p className="muted">A személy születési adatai csak a felvételt követő egy órán belül javíthatók.</p>
<Link href={`/kepletek/${id}`} className="btn" style={{ alignSelf: "flex-start" }}>
Vissza a képlethez
</Link>
</>
)}
</section>
</main>
);
}
@@ -1,16 +1,21 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { BigThree, ChartTables } from "@/components/ChartTables";
import { AspectGrid, AspectList, BigThree, PositionTables } from "@/components/ChartTables";
import { ChartSummary } from "@/components/ChartSummary";
import { ChartSwitcher } from "@/components/ChartSwitcher";
import { DetailedAnalysis } from "@/components/DetailedAnalysis";
import { ChartWheel, WheelLegend } from "@/components/ChartWheel";
import { ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
import { Tabs } from "@/components/Tabs";
import { ASPECTS, ELEMENTS, MODALITIES, MOON_PHASES, countryName, formatBirthDate, pointName } from "@/lib/astro";
import { backendGet, requireMe } from "@/lib/server";
import type { Analysis, Chart, PublicConfig } from "@/lib/types";
import type { Analysis, Chart, ChartListItem, PublicConfig } from "@/lib/types";
export const metadata: Metadata = { title: "Képlet" };
const GRID_LEGEND = ["conjunction", "sextile", "square", "trine", "opposition"];
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
/** One saved chart: the wheel and the tables, read from the database (not recalculated). */
@@ -18,11 +23,14 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
const { id } = await params;
const me = await requireMe(`/kepletek/${id}`);
if (!UUID.test(id)) notFound();
const [chart, analyses, config] = await Promise.all([
const [chart, analyses, config, chartList] = await Promise.all([
backendGet<Chart>(`/v1/charts/${id}`),
backendGet<{ analyses: Analysis[] }>(`/v1/charts/${id}/analyses`),
backendGet<PublicConfig>("/v1/config"),
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
]);
const charts = chartList?.charts ?? [];
const persons = charts.filter((c) => c.kind === "person");
if (!chart) notFound();
const list = analyses?.analyses ?? [];
const summary = list.find((a) => a.kind === "summary" && a.status !== "failed") ?? null;
@@ -40,7 +48,13 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
return (
<main className="page" style={{ maxWidth: 1180 }}>
<div className="page-head">
<h1>{chart.is_primary ? "Születési képletem" : chart.label}</h1>
<ChartSwitcher
title={chart.is_primary ? "Születési képletem" : chart.label}
currentId={chart.id}
own={charts.find((c) => c.is_primary) ?? null}
persons={persons}
canAdd={me.persons.left !== 0}
/>
<p className="muted">
{formatBirthDate(chart.birth_data.date)}
{timeKnown ? `, ${result.time.local.slice(11, 16)} (UTC${result.time.utc_offset}${result.time.dst ? ", nyári idő" : ""})` : ", ismeretlen időpont"}
@@ -55,8 +69,8 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
<ChartWheel chart={result} timeKnown={timeKnown} />
<WheelLegend />
</div>
<div className="field" style={{ gap: 16 }}>
<ChartSummary chartId={chart.id} initial={summary} />
<div className="field chart-side">
<ChartSummary chartId={chart.id} initial={summary} detailedDone={detailed?.status === "done"} />
<BigThree chart={chart} />
{(elements || modalities || phase) && (
<div className="card" style={{ gap: 12 }}>
@@ -102,9 +116,33 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
)}
</div>
)}
{chart.is_primary && (
<Link href="/szemelyek" className="card persons-tile">
<span className="eyebrow">Személyek</span>
<strong>
{persons.length > 0 ? `${persons.length} felvett személy` : "Társad, családod képlete"}
</strong>
<span className="muted">
{persons.length > 0
? persons.slice(0, 3).map((p) => p.label).join(", ") + (persons.length > 3 ? "…" : "")
: "Vedd fel őket, és nézd meg az ő képletüket és elemzésüket is."}
</span>
<span className="persons-tile-arrow" aria-hidden="true">
→
</span>
</Link>
)}
</div>
</section>
<section className="card chart-tabs" aria-label="Elemzés és táblázatok">
<Tabs
label="Képlet részletei"
tabs={[
{
id: "elemzes",
label: "Elemzés",
content: (
<DetailedAnalysis
chartId={chart.id}
initial={detailed}
@@ -112,10 +150,31 @@ export default async function ChartPage({ params }: { params: Promise<{ id: stri
isAdmin={me.user.roles.includes("admin")}
canPay={config?.mock_payments ?? false}
/>
<section className="card" aria-labelledby="positions">
<h2 id="positions">Pozíciók</h2>
<ChartTables chart={chart} />
),
},
{ id: "bolygok", label: "Bolygók", content: <PositionTables chart={chart} /> },
{
id: "matrix",
label: "Mátrix",
content: (
<div className="field" style={{ gap: 16 }}>
<AspectGrid chart={chart} />
<ul className="grid-legend" aria-label="Jelmagyarázat">
{GRID_LEGEND.map((k) => (
<li key={k}>
<span className={`sym asp asp-${k}`} aria-hidden="true">
{ASPECTS[k]?.glyph}
</span>{" "}
{ASPECTS[k]?.hu}
</li>
))}
</ul>
</div>
),
},
{ id: "reszletek", label: "Részletek", content: <AspectList chart={chart} /> },
]}
/>
</section>
</main>
);
@@ -0,0 +1,6 @@
import { redirect } from "next/navigation";
// The persons list moved to /szemelyek.
export default function ChartsIndex() {
redirect("/szemelyek");
}
@@ -0,0 +1,71 @@
"use client";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
/** GDPR: download all data, delete the account. */
export function AccountData() {
const [confirm, setConfirm] = useState(false);
const [typed, setTyped] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
async function remove() {
setBusy(true);
setError(null);
try {
await api("/me", { method: "DELETE", body: { confirm: "DELETE" } });
window.location.href = "/belepes";
} catch (e) {
setError(errorText(e));
setBusy(false);
}
}
return (
<div className="field" style={{ gap: 16 }}>
<div className="form-actions">
<a href="/api/v1/me/export" className="btn" download>
Adataim letöltése
</a>
<span className="hint">Minden adatod egy JSON-fájlban: fiók, képletek, elemzések, vásárlások.</span>
</div>
{confirm ? (
<div className="danger-box">
<p>
A fiókod végleg törlődik a képleteiddel, a felvett személyekkel és az összes elemzéssel együtt. Ez nem
vonható vissza. A megerősítéshez írd be: <strong>TÖRLÉS</strong>
</p>
<input
className="inp"
style={{ maxWidth: 240 }}
value={typed}
onChange={(e) => setTyped(e.target.value)}
aria-label="Írd be: TÖRLÉS"
autoComplete="off"
/>
<div className="form-actions">
<button type="button" className="btn btn-danger" onClick={remove} disabled={busy || typed.trim() !== "TÖRLÉS"}>
{busy ? "Törlés…" : "Fiók végleges törlése"}
</button>
<button type="button" className="btn btn-ghost" onClick={() => setConfirm(false)} disabled={busy}>
Mégse
</button>
</div>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</div>
) : (
<div className="form-actions">
<button type="button" className="btn btn-ghost" style={{ color: "var(--danger)" }} onClick={() => setConfirm(true)}>
Fiók törlése
</button>
</div>
)}
</div>
);
}
+35 -9
View File
@@ -16,15 +16,22 @@ const ERRORS: Record<string, string> = {
invalid_date: "Érvénytelen dátum.",
};
/** Someone else's chart: added with a name, or (with `chartId`) corrected. */
export type PersonTarget = { chartId?: string; name?: string };
export function BirthForm({
initial,
person,
onCancel,
onSaved,
}: {
initial: Initial;
/** Not given: the user's own birth data. */
person?: PersonTarget;
onCancel?: () => void;
onSaved: (chartId: string) => void;
}) {
const [name, setName] = useState(person?.name ?? "");
const [date, setDate] = useState(initial?.date ?? "");
const [time, setTime] = useState(initial?.time?.slice(0, 5) ?? "");
const [timeUnknown, setTimeUnknown] = useState(initial ? !initial.time : false);
@@ -49,23 +56,28 @@ export function BirthForm({
async function submit(e: React.FormEvent) {
e.preventDefault();
setError(null);
if (person && !name.trim()) return setError("Add meg a nevét.");
if (!date) return setError("Add meg a születési dátumot.");
if (!timeUnknown && !time) return setError("Add meg a születési időt, vagy jelöld, hogy nem tudod.");
if (!place) return setError("Válaszd ki a születési helyet a listából.");
setBusy(true);
try {
const saved = await api<{ id: string }>("/charts", {
body: {
label: "Saját képlet",
is_primary: true,
birth: {
const birth = {
date,
...(timeUnknown ? {} : { time }),
country,
geonames_id: place.geonames_id,
...(ambiguous ? { ambiguous_time: ambiguity } : {}),
},
},
};
const saved = person?.chartId
? await api<{ id: string }>(`/charts/${person.chartId}`, {
method: "PATCH",
body: { label: name.trim(), birth },
})
: await api<{ id: string }>("/charts", {
body: person
? { label: name.trim(), is_primary: false, birth }
: { label: "Saját képlet", is_primary: true, birth },
});
onSaved(saved.id);
} catch (err) {
@@ -84,6 +96,20 @@ export function BirthForm({
return (
<form onSubmit={submit} className="field" style={{ gap: 18 }} noValidate>
{person && (
<div className="field" style={{ maxWidth: 420 }}>
<label htmlFor="person-name">Név</label>
<input
id="person-name"
className="inp"
value={name}
maxLength={100}
autoComplete="off"
onChange={(e) => setName(e.target.value)}
required
/>
</div>
)}
<div className="grid-2">
<div className="field">
<label htmlFor="birth-date">Születési dátum</label>
@@ -132,7 +158,7 @@ export function BirthForm({
{ambiguous && (
<fieldset className="field" style={{ border: 0, padding: 0, margin: 0 }}>
<legend className="label" style={{ marginBottom: 8 }}>
Melyik időpontban születtél?
{person ? "Melyik időpontban született?" : "Melyik időpontban születtél?"}
</legend>
<label className="check">
<input type="radio" name="ambiguity" checked={ambiguity === "earlier"} onChange={() => setAmbiguity("earlier")} />
@@ -152,7 +178,7 @@ export function BirthForm({
)}
<div className="form-actions">
<button type="submit" className="btn btn-primary" disabled={busy}>
{busy ? "Számolás…" : "Mentés és képlet számítása"}
{busy ? "Számolás…" : person?.chartId ? "Javítás mentése" : "Mentés és képlet számítása"}
</button>
{onCancel && (
<button type="button" className="btn btn-ghost" onClick={onCancel} disabled={busy}>
+14
View File
@@ -1,9 +1,11 @@
import type { Metadata } from "next";
import Link from "next/link";
import { ROLE_LABELS, formatDate } from "@/lib/astro";
import { backendGet, requireMe } from "@/lib/server";
import type { Chart } from "@/lib/types";
import { AccountData } from "./AccountData";
import { BirthEditor } from "./BirthEditor";
import { ProfileForm } from "./ProfileForm";
@@ -46,6 +48,10 @@ export default async function ProfilePage() {
<dd>
{me.analyses_left.natal} képlet, {me.analyses_left.synastry} szinasztria
</dd>
<dt>Személyek</dt>
<dd>
{me.persons.unlimited ? `${me.persons.used} felvéve, korlátlan` : `${me.persons.used} / ${me.persons.limit} hely`}
</dd>
<dt>Tag óta</dt>
<dd>{formatDate(user.created_at)}</dd>
</dl>
@@ -76,6 +82,14 @@ export default async function ProfilePage() {
notice={me.birth_change.notice}
/>
</section>
<section className="card" aria-labelledby="adataim">
<h2 id="adataim">Adataim</h2>
<p className="muted">
Hogyan kezeljük az adataidat: <Link href="/adatvedelem">adatvédelmi tájékoztató</Link>.
</p>
<AccountData />
</section>
</main>
);
}
@@ -0,0 +1,78 @@
import type { Metadata } from "next";
import Link from "next/link";
import { ChartCard } from "@/components/ChartCard";
import { PersonActions } from "@/components/PersonActions";
import { PersonPacks } from "@/components/PersonPacks";
import { backendGet, requireMe } from "@/lib/server";
import type { ChartListItem, PublicConfig } from "@/lib/types";
export const metadata: Metadata = { title: "Személyek" };
/** The persons the user added, with room for a new one. */
export default async function PersonsPage() {
const me = await requireMe("/szemelyek");
const [list, config] = await Promise.all([
backendGet<{ charts: ChartListItem[] }>("/v1/charts"),
backendGet<PublicConfig>("/v1/config"),
]);
const charts = list?.charts ?? [];
const persons = charts.filter((c) => c.kind === "person");
const isAdmin = me.user.roles.includes("admin");
const slots = me.persons;
const full = slots.left === 0;
const now = Date.now();
return (
<main className="page" style={{ maxWidth: 1080 }}>
<div className="page-head">
<h1>Személyek</h1>
<p className="muted">
Társad, családtagjaid, barátaid képlete. Mindegyikhez kérhetsz részletes elemzést, és a képletoldal címére
kattintva válthatsz köztük.
</p>
</div>
<div className="chart-cards">
{persons.map((p) => (
<ChartCard key={p.id} chart={p} title={p.label}>
<PersonActions
id={p.id}
name={p.label}
editable={isAdmin || (p.editable_until !== null && Date.parse(p.editable_until) > now)}
/>
</ChartCard>
))}
{!full && (
<Link href="/szemelyek/uj" className="chart-card chart-card-new">
<span className="chart-card-plus" aria-hidden="true">
+
</span>
<strong className="chart-card-name">Új személy</strong>
<span className="muted">
{slots.unlimited ? "Korlátlan számú személy" : `Még ${slots.left} személyt vehetsz fel`}
</span>
</Link>
)}
</div>
{!slots.unlimited && (
<section className="card" aria-labelledby="slots-title">
<div className="card-head">
<h2 id="slots-title">Személyek</h2>
<span className="badge">
{slots.used} / {slots.limit} hely
</span>
</div>
<p className="muted">
{full
? "Elfogytak a helyeid. Újabb személyhez válassz csomagot."
: "A felvett személyek képletét és elemzéseit itt éred el. Egy törölt személy helye nem szabadul fel."}
</p>
<PersonPacks packSize={config?.person_pack_size ?? 5} canPay={config?.mock_payments ?? false} />
</section>
)}
</main>
);
}
@@ -0,0 +1,17 @@
"use client";
import { useRouter } from "next/navigation";
import { BirthForm } from "@/app/profil/BirthForm";
export function NewPerson() {
const router = useRouter();
return (
<BirthForm
initial={null}
person={{}}
onCancel={() => router.push("/szemelyek")}
onSaved={(id) => router.push(`/kepletek/${id}`)}
/>
);
}
@@ -0,0 +1,40 @@
import type { Metadata } from "next";
import { PersonPacks } from "@/components/PersonPacks";
import { backendGet, requireMe } from "@/lib/server";
import type { PublicConfig } from "@/lib/types";
import { NewPerson } from "./NewPerson";
export const metadata: Metadata = { title: "Új személy" };
export default async function NewPersonPage() {
const me = await requireMe("/szemelyek/uj");
const config = await backendGet<PublicConfig>("/v1/config");
const slots = me.persons;
return (
<main className="page">
<div className="page-head">
<h1>Új személy</h1>
<p className="muted">
Társad, családtagod, barátod: a születési adataiból elkészül a képlete és egy rövid összefoglaló.
{!slots.unlimited && slots.left !== null && slots.left > 0 && ` Még ${slots.left} személyt vehetsz fel.`}
</p>
</div>
<section className="card" aria-label="Születési adatok">
{slots.left === 0 ? (
<>
<p className="muted">Elfogytak a helyeid. Újabb személyhez válassz csomagot.</p>
<PersonPacks packSize={config?.person_pack_size ?? 5} canPay={config?.mock_payments ?? false} />
</>
) : (
<>
<NewPerson />
<p className="hint">Az adatokat a felvételt követő egy órán belül még javíthatod, utána nem módosíthatók.</p>
</>
)}
</section>
</main>
);
}
@@ -0,0 +1,43 @@
import Link from "next/link";
import { SIGNS, formatBirthDate } from "@/lib/astro";
import type { ChartListItem } from "@/lib/types";
/** Sun, Moon and Ascendant sign glyphs of a chart. */
export function SignTrio({ chart }: { chart: ChartListItem }) {
const h = chart.highlights;
const items: [string, string | null][] = [
["☉", h.sun],
["☽", h.moon],
["AC", h.time_known ? h.ascendant : null],
];
return (
<span className="sign-trio" aria-hidden="true">
{items.map(([k, sign]) => (
<span key={k}>
<span className={k === "AC" ? "trio-ac" : "sym"}>{k}</span>
<span className="sym trio-sign">{sign ? SIGNS[sign]?.glyph : "–"}</span>
</span>
))}
</span>
);
}
/** One chart in the list: name, birth date and place, the three main signs. */
export function ChartCard({ chart, title, children }: { chart: ChartListItem; title: string; children?: React.ReactNode }) {
const { birth } = chart;
return (
<div className="chart-card">
<Link href={`/kepletek/${chart.id}`} className="chart-card-link">
<strong className="chart-card-name">{title}</strong>
<span className="muted">
{formatBirthDate(birth.date)}
{birth.time ? `, ${birth.time.slice(0, 5)}` : ""}
{birth.place ? ` · ${birth.place}` : ""}
</span>
<SignTrio chart={chart} />
</Link>
{children}
</div>
);
}
@@ -7,6 +7,7 @@ import type { Analysis } from "@/lib/types";
import { AnalysisLoading } from "./AnalysisLoading";
import { Rich } from "./Rich";
import { openTab } from "./Tabs";
const POLL_MS = 3000;
const MAX_POLLS = 60;
@@ -16,7 +17,16 @@ const MAX_POLLS = 60;
* saved; this asks for it (queueing it again if it failed) and polls until the
* worker has written it.
*/
export function ChartSummary({ chartId, initial }: { chartId: string; initial: Analysis | null }) {
export function ChartSummary({
chartId,
initial,
detailedDone = false,
}: {
chartId: string;
initial: Analysis | null;
/** The detailed analysis is ready: the link says so instead of offering it. */
detailedDone?: boolean;
}) {
const [summary, setSummary] = useState<Analysis | null>(initial);
const [gaveUp, setGaveUp] = useState(false);
const done = summary?.status === "done";
@@ -57,6 +67,17 @@ export function ChartSummary({ chartId, initial }: { chartId: string; initial: A
<p className="summary-text">
<Rich text={content.summary ?? ""} />
</p>
<a
href="#elemzes"
className="summary-more"
onClick={(e) => {
e.preventDefault();
openTab("elemzes");
}}
>
{detailedDone ? "Elolvasom a részletes elemzést" : "Kérj részletes elemzést: hat fejezet a képletedről"}
<span aria-hidden="true"> →</span>
</a>
</>
) : (
<>
@@ -0,0 +1,93 @@
"use client";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useEffect, useRef, useState } from "react";
import { formatBirthDate } from "@/lib/astro";
import type { ChartListItem } from "@/lib/types";
/**
* The chart page title as a menu of the user's charts. Switching keeps the
* open tab (#matrix etc.), so two people's charts are easy to compare.
*/
export function ChartSwitcher({
title,
currentId,
own,
persons,
canAdd,
}: {
title: string;
currentId: string;
own: ChartListItem | null;
persons: ChartListItem[];
canAdd: boolean;
}) {
const router = useRouter();
const [open, setOpen] = useState(false);
const root = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const close = (e: MouseEvent | KeyboardEvent) => {
if (e instanceof KeyboardEvent ? e.key === "Escape" : !root.current?.contains(e.target as Node)) setOpen(false);
};
document.addEventListener("mousedown", close);
document.addEventListener("keydown", close);
return () => {
document.removeEventListener("mousedown", close);
document.removeEventListener("keydown", close);
};
}, [open]);
function go(e: React.MouseEvent, id: string) {
e.preventDefault();
setOpen(false);
router.push(`/kepletek/${id}${window.location.hash}`);
}
const items = [...(own ? [{ chart: own, name: "Én" }] : []), ...persons.map((p) => ({ chart: p, name: p.label }))];
return (
<div className="switcher" ref={root}>
<h1>
<button
type="button"
className="switcher-button"
aria-haspopup="true"
aria-expanded={open}
onClick={() => setOpen((o) => !o)}
>
{title}
<span className="switcher-caret" aria-hidden="true">
▾
</span>
<span className="sr-only">: másik képlet választása</span>
</button>
</h1>
{open && (
<div className="switcher-menu">
<ul>
{items.map(({ chart, name }) => (
<li key={chart.id}>
<a
href={`/kepletek/${chart.id}`}
aria-current={chart.id === currentId ? "page" : undefined}
onClick={(e) => go(e, chart.id)}
>
<strong>{name}</strong>
<span className="muted">{formatBirthDate(chart.birth.date)}</span>
</a>
</li>
))}
</ul>
<div className="switcher-foot">
{canAdd && <Link href="/szemelyek/uj">+ Új személy</Link>}
<Link href="/szemelyek">Személyek</Link>
</div>
</div>
)}
</div>
);
}
@@ -67,8 +67,8 @@ const GRID_ANGLES: [string, string][] = [
["midheaven", "MC"],
];
/** The usual triangular aspect grid: only the aspect symbols, the values are in the details below. */
function AspectGrid({ chart }: { chart: Chart }) {
/** The aspect grid: a square matrix with the points on both sides, only the aspect symbols in it. */
export function AspectGrid({ chart }: { chart: Chart }) {
const result = chart.chart;
const present = new Set(result.points.map((p) => p.id));
const rows: [string, string][] = GRID_POINTS.filter((id) => present.has(id)).map((id) => [
@@ -83,17 +83,38 @@ function AspectGrid({ chart }: { chart: Chart }) {
byPair.set(`${a.point1}|${a.point2}`, a);
byPair.set(`${a.point2}|${a.point1}`, a);
}
const label = ([id, text]: [string, string]) => (
<span className={text.length > 2 ? "sym" : "grid-angle"} aria-label={pointName(id)} role="img">
{text}
</span>
);
return (
<div className="aspect-grid-wrap">
<table className="aspect-grid" aria-label="Fényszögmátrix">
<thead>
<tr>
<td className="corner" />
{rows.map((c) => (
<th key={c[0]} scope="col" title={pointName(c[0])}>
{label(c)}
</th>
))}
</tr>
</thead>
<tbody>
{rows.map(([id, label], i) => (
{rows.map((row) => {
const [id] = row;
return (
<tr key={id}>
{rows.slice(0, i).map(([other]) => {
<th scope="row" title={pointName(id)}>
{label(row)}
</th>
{rows.map(([other]) => {
if (other === id) return <td key={other} className="diag" />;
const a = byPair.get(`${id}|${other}`);
const info = a ? ASPECTS[a.aspect] : undefined;
const text = a ? `${pointName(other)} ${info?.hu ?? a.aspect} ${pointName(id)}` : undefined;
const text = a ? `${pointName(id)} ${info?.hu ?? a.aspect} ${pointName(other)}` : undefined;
return (
<td key={other} title={text}>
{a && (
@@ -104,28 +125,23 @@ function AspectGrid({ chart }: { chart: Chart }) {
</td>
);
})}
<th scope="row" title={pointName(id)}>
<span className={label.length > 2 ? "sym" : "grid-angle"} aria-label={pointName(id)} role="img">
{label}
</span>
</th>
</tr>
))}
);
})}
</tbody>
</table>
</div>
);
}
/** Positions, angles, house cusps and aspects of a natal chart. */
export function ChartTables({ chart }: { chart: Chart }) {
/** Positions, angles and house cusps of a natal chart. */
export function PositionTables({ chart }: { chart: Chart }) {
const result = chart.chart;
const timeKnown = chart.highlights.time_known;
const angles = ANGLES.map(([key, label]) => [label, result.angles?.[key]] as const).filter(
(a): a is readonly [string, Position] => typeof a[1] === "object" && a[1] !== null,
);
const fortune = result.lots?.fortune;
const aspects = [...(result.aspects ?? [])].sort((a, b) => a.orb - b.orb);
return (
<div className="field" style={{ gap: 24 }}>
@@ -210,12 +226,21 @@ export function ChartTables({ chart }: { chart: Chart }) {
</div>
)}
</div>
{aspects.length > 0 && (
<div className="field" style={{ gap: 12 }}>
<h3>Fényszögek</h3>
<AspectGrid chart={chart} />
<details className="details">
<summary>Részletek: orbisz, közeledő vagy távolodó</summary>
{!timeKnown && (
<p className="hint">
Születési idő nélkül a házak, a tengelyek és az Aszcendens nem számolhatók; a Hold helyzete a nap folyamán akár
jegyet is válthat, ezért közelítő.
</p>
)}
</div>
);
}
/** Every aspect with its orb and whether it is applying, closest first. */
export function AspectList({ chart }: { chart: Chart }) {
const aspects = [...(chart.chart.aspects ?? [])].sort((a, b) => a.orb - b.orb);
if (aspects.length === 0) return <p className="muted">Nincs fényszög.</p>;
return (
<div className="table-wrap">
<table>
<thead>
@@ -258,15 +283,5 @@ export function ChartTables({ chart }: { chart: Chart }) {
</tbody>
</table>
</div>
</details>
</div>
)}
{!timeKnown && (
<p className="hint">
Születési idő nélkül a házak, a tengelyek és az Aszcendens nem számolhatók; a Hold helyzete a nap folyamán akár
jegyet is válthat, ezért közelítő.
</p>
)}
</div>
);
}
@@ -78,7 +78,7 @@ export function DetailedAnalysis({
if (analysis?.status === "done" && analysis.content) {
return (
<section className="card analysis-card" aria-label="Részletes elemzés">
<section className="analysis-card" aria-label="Részletes elemzés">
<span className="eyebrow">Részletes elemzés</span>
<AnalysisView content={analysis.content} />
</section>
@@ -87,7 +87,7 @@ export function DetailedAnalysis({
if (waiting) {
return (
<section className="card analysis-card" aria-label="Részletes elemzés" aria-busy="true">
<section className="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"
@@ -98,9 +98,11 @@ export function DetailedAnalysis({
}
return (
<section className="card analysis-card" aria-labelledby="detailed-title">
<section className="analysis-card analysis-offer" aria-labelledby="detailed-title">
<div className="offer-head">
<span className="eyebrow">Részletes elemzés</span>
<h2 id="detailed-title">Az egész képleted, fejezetekre bontva</h2>
</div>
<p className="muted">
Kb. 1500 szó hat fejezetben: személyiség, érzelmek, gondolkodás, szerelem és kapcsolatok, hivatás, fejlődési ú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.
@@ -0,0 +1,59 @@
"use client";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
/** Correct (while allowed) or delete a person. */
export function PersonActions({ id, name, editable }: { id: string; name: string; editable: boolean }) {
const router = useRouter();
const [confirm, setConfirm] = useState(false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
async function remove() {
setBusy(true);
setError(null);
try {
await api(`/charts/${id}`, { method: "DELETE" });
router.refresh();
} catch (e) {
setError(errorText(e));
setBusy(false);
}
}
return (
<div className="person-actions">
{confirm ? (
<>
<span className="hint">Törlöd {name} képletét és elemzéseit? A hely nem szabadul fel.</span>
<button type="button" className="btn btn-sm btn-danger" onClick={remove} disabled={busy}>
{busy ? "Törlés…" : "Igen, törlöm"}
</button>
<button type="button" className="btn btn-sm btn-ghost" onClick={() => setConfirm(false)} disabled={busy}>
Mégse
</button>
</>
) : (
<>
{editable && (
<Link href={`/kepletek/${id}/javitas`} className="btn btn-sm btn-ghost">
Adatok javítása
</Link>
)}
<button type="button" className="btn btn-sm btn-ghost" onClick={() => setConfirm(true)}>
Törlés
</button>
</>
)}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
</div>
);
}
@@ -0,0 +1,64 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
/**
* Person packages: a few more persons, or any number. Until Stripe is
* connected the payment is a stand-in (MOCK_PAYMENTS) that grants it at once.
*/
export function PersonPacks({ packSize, canPay }: { packSize: number; canPay: boolean }) {
const router = useRouter();
const [busy, setBusy] = useState<string | null>(null);
const [error, setError] = useState<string | null>(null);
async function buy(pkg: "persons" | "persons_unlimited") {
setBusy(pkg);
setError(null);
try {
await api("/payments/mock", { body: { package: pkg } });
router.refresh();
} catch (e) {
setError(errorText(e));
} finally {
setBusy(null);
}
}
if (!canPay) {
return <p className="hint">További személyekhez csomag kell; a csomagok hamarosan elérhetők.</p>;
}
return (
<div className="field" style={{ gap: 12 }}>
<div className="packs">
<div className="pack">
<strong>+{packSize} személy</strong>
<span className="muted">Még {packSize} ember képlete és elemzése.</span>
<button type="button" className="btn btn-primary btn-sm" onClick={() => buy("persons")} disabled={busy !== null}>
{busy === "persons" ? "Fizetés…" : "Fizetés"}
</button>
</div>
<div className="pack">
<strong>Korlátlan</strong>
<span className="muted">Bárkit felvehetsz, nincs felső határ.</span>
<button
type="button"
className="btn btn-primary btn-sm"
onClick={() => buy("persons_unlimited")}
disabled={busy !== null}
>
{busy === "persons_unlimited" ? "Fizetés…" : "Fizetés"}
</button>
</div>
</div>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<p className="hint">Tesztüzem: a fizetés még nincs bekötve, a gomb nem terhel semmit.</p>
</div>
);
}
@@ -16,6 +16,7 @@ export function Logo() {
export function SiteHeader({ me }: { me: Me }) {
const links = [
{ href: "/keplet", label: "Képletem" },
{ href: "/szemelyek", label: "Személyek" },
{ href: "/profil", label: "Profil" },
];
if (me.user.roles.includes("admin")) links.push({ href: "/admin", label: "Admin" });
+89
View File
@@ -0,0 +1,89 @@
"use client";
import { type KeyboardEvent, type ReactNode, useEffect, useRef, useState } from "react";
export type Tab = { id: string; label: string; content: ReactNode };
/**
* Tabs with the chosen one kept in the URL hash (#matrix), so a reload or a
* shared link opens the same tab. Hidden panels stay mounted: a running
* analysis keeps polling while another tab is open.
*/
/** Opens a tab from anywhere on the page (also when the hash is already that tab). */
export function openTab(id: string) {
history.replaceState(null, "", `#${id}`);
window.dispatchEvent(new HashChangeEvent("hashchange"));
}
export function Tabs({ tabs, label }: { tabs: Tab[]; label: string }) {
const [active, setActive] = useState(tabs[0]?.id);
const buttons = useRef<(HTMLButtonElement | null)[]>([]);
const root = useRef<HTMLDivElement>(null);
// A link to #<tab> (on load, or from elsewhere on the page) opens that tab and scrolls to it.
useEffect(() => {
const open = () => {
const id = window.location.hash.slice(1);
if (!tabs.some((t) => t.id === id)) return;
setActive(id);
root.current?.scrollIntoView({ behavior: "smooth", block: "start" });
};
open();
window.addEventListener("hashchange", open);
return () => window.removeEventListener("hashchange", open);
}, [tabs]);
function choose(id: string) {
setActive(id);
history.replaceState(null, "", `#${id}`);
}
function onKey(e: KeyboardEvent, i: number) {
const step = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
const to = e.key === "Home" ? 0 : e.key === "End" ? tabs.length - 1 : step ? (i + step + tabs.length) % tabs.length : -1;
if (to < 0) return;
e.preventDefault();
choose(tabs[to].id);
buttons.current[to]?.focus();
}
return (
<div className="tabs" ref={root}>
<div className="tab-list" role="tablist" aria-label={label}>
{tabs.map((t, i) => (
<button
key={t.id}
ref={(el) => {
buttons.current[i] = el;
}}
type="button"
role="tab"
id={`tab-${t.id}`}
aria-controls={`panel-${t.id}`}
aria-selected={active === t.id}
tabIndex={active === t.id ? 0 : -1}
className="tab"
onClick={() => choose(t.id)}
onKeyDown={(e) => onKey(e, i)}
>
{t.label}
</button>
))}
</div>
{tabs.map((t) => (
<div
key={t.id}
role="tabpanel"
id={`panel-${t.id}`}
aria-labelledby={`tab-${t.id}`}
hidden={active !== t.id}
className="tab-panel"
tabIndex={0}
>
{t.content}
</div>
))}
</div>
);
}
+10
View File
@@ -0,0 +1,10 @@
// Operator details shown on the legal pages. Fill these in before launch.
export const OPERATOR = {
name: "[Üzemeltető neve – kitöltendő]",
address: "[Székhely / postacím – kitöltendő]",
email: "[Kapcsolattartási e-mail – kitöltendő]",
/** Company registration and tax number, if the operator is a company. */
registration: null as string | null,
};
export const PRIVACY_UPDATED = "2026. november 17.";
+27
View File
@@ -18,6 +18,15 @@ export interface Me {
primary_chart_id: string | null;
analyses_left: UnitBalance;
birth_change: BirthChange;
persons: PersonSlots;
}
/** How many persons the user may still add (`left`/`limit` null: no limit). */
export interface PersonSlots {
used: number;
limit: number | null;
left: number | null;
unlimited: boolean;
}
/** Limit on changing the own birth data (the notice text comes from the backend). */
@@ -41,6 +50,7 @@ export interface PublicConfig {
password_login: boolean;
password_min_length: number;
mock_payments: boolean;
person_pack_size: number;
}
export interface Position {
@@ -87,16 +97,33 @@ export interface BirthData {
geonames_id?: number | null;
}
export type ChartKind = "own" | "person";
export interface Chart {
id: string;
label: string;
is_primary: boolean;
kind: ChartKind;
/** A person's birth data can be corrected until then (admins: any time). */
editable_until: string | null;
birth_data: BirthData;
highlights: { sun: string | null; moon: string | null; ascendant: string | null; time_known: boolean };
chart: ChartResult;
created_at: string;
}
/** A chart in the list (`GET /v1/charts`). */
export interface ChartListItem {
id: string;
label: string;
is_primary: boolean;
kind: ChartKind;
editable_until: string | null;
birth: { date: string; time: string | null; place: string | null };
highlights: Chart["highlights"];
created_at: string;
}
export interface Analysis {
id: string;
kind: "natal" | "synastry" | "summary";
+4 -4
View File
@@ -269,8 +269,8 @@ mod analyses {
.await
.unwrap();
sqlx::query(
"INSERT INTO charts (id, owner_id, label, is_primary, birth_data, result, chart_hash) \
VALUES ($1, $2, 'Saját', true, '{}', $3, 'hash1')",
"INSERT INTO charts (id, owner_id, label, is_primary, kind, birth_data, result, chart_hash) \
VALUES ($1, $2, 'Saját', true, 'own', '{}', $3, 'hash1')",
)
.bind(chart)
.bind(user)
@@ -424,8 +424,8 @@ mod analyses {
let response = fixture("synastry-response.json");
let (chart2, synastry) = (Uuid::now_v7(), Uuid::now_v7());
sqlx::query(
"INSERT INTO charts (id, owner_id, label, is_primary, birth_data, result, chart_hash) \
VALUES ($1, $2, 'Partner', false, '{}', $3, 'hash2')",
"INSERT INTO charts (id, owner_id, label, is_primary, kind, birth_data, result, chart_hash) \
VALUES ($1, $2, 'Partner', false, 'person', '{}', $3, 'hash2')",
)
.bind(chart2)
.bind(s.user)