Files
sorsfonalak/services/frontend/src/components/AnalysisView.tsx
T
fecoandClaude Opus 5.5 ce3d3804a7 Paid detailed analyses with per-kind units; example analysis page
- Credits become analysis units (migration 0006): a natal analysis uses
  one 'natal' unit, a synastry analysis one 'synastry' unit. No monthly
  free credits, no model tiers: ANALYSIS_MODEL (default Opus 5.5) writes
  every paid analysis. Admins grant units per kind; the worker refunds
  the right unit on failure.
- Chart page: the detailed analysis card (offer with units left and a
  confirmation, progress while writing, the finished six sections).
- Public /pelda page: a full Opus analysis of a made-up chart, with the
  free summary and a login call to action.
- The worker sends the JSON schema with properties in 'required' order.
  serde_json sorted them, so the title came after ~9000 tokens of text
  and Opus sometimes left it empty (3 failed attempts in a live test);
  with the order fixed the same analysis succeeded at the first try.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-16 17:39:15 +00:00

63 lines
2.0 KiB
TypeScript

import type { AnalysisContent } from "@/lib/types";
import { Paragraphs, Rich } from "./Rich";
const NATAL_ORDER = ["personality", "emotions", "mind", "love", "work", "growth"];
const SYNASTRY_ORDER = ["attraction", "communication", "emotional_bond", "friction", "long_term"];
/** A finished detailed analysis (natal or synastry). */
export function AnalysisView({ content, kind = "natal" }: { content: AnalysisContent; kind?: "natal" | "synastry" }) {
const order = kind === "synastry" ? SYNASTRY_ORDER : NATAL_ORDER;
const sections = order.map((key) => content.sections?.[key]).filter((s) => s !== undefined);
return (
<article className="analysis">
<header className="analysis-head">
<h2>{content.title}</h2>
{content.summary && (
<p className="analysis-lead">
<Rich text={content.summary} />
</p>
)}
</header>
{sections.map((s, i) => (
<section key={i} className="analysis-section">
<h3>{s.title}</h3>
<Paragraphs text={s.body} />
</section>
))}
<div className="analysis-lists">
{content.strengths && content.strengths.length > 0 && (
<section>
<h3>Erősségek</h3>
<ul>
{content.strengths.map((t, i) => (
<li key={i}>
<Rich text={t} />
</li>
))}
</ul>
</section>
)}
{content.challenges && content.challenges.length > 0 && (
<section>
<h3>Kihívások</h3>
<ul>
{content.challenges.map((t, i) => (
<li key={i}>
<Rich text={t} />
</li>
))}
</ul>
</section>
)}
</div>
{content.advice && (
<section className="analysis-section analysis-advice">
<h3>Útravaló</h3>
<Paragraphs text={content.advice} />
</section>
)}
</article>
);
}