Questions in a chat panel behind a floating button
Where a finished detailed analysis can be asked about (chart, comparison, forecast), a floating button with the silhouette icon opens a chat panel (a side panel on desktop, full screen on phones): earlier questions and answers as bubbles, the question box at the bottom, or a one-line package offer when no questions are left. The end of the analysis keeps a short line that opens the same panel; the button hides while that line is in view. The panel stays mounted when closed, so an answer keeps arriving and the button shows a dot for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -21,6 +21,7 @@ export function PackageCards({
|
||||
ids,
|
||||
canPay,
|
||||
compact = false,
|
||||
row = false,
|
||||
onBought,
|
||||
}: {
|
||||
packages: Package[];
|
||||
@@ -29,6 +30,8 @@ export function PackageCards({
|
||||
/** How the user can pay (null: purchases are off, the buttons say "soon"). */
|
||||
canPay: PayMethod | null;
|
||||
compact?: boolean;
|
||||
/** One line per package (name, price, button), for tight places like the question panel. */
|
||||
row?: boolean;
|
||||
/** After a stand-in purchase (default: reload the page data). */
|
||||
onBought?: (p: Package) => Promise<void> | void;
|
||||
}) {
|
||||
@@ -83,61 +86,78 @@ export function PackageCards({
|
||||
}
|
||||
}
|
||||
|
||||
const buyButton = (p: Package) =>
|
||||
canPay ? (
|
||||
<button
|
||||
type="button"
|
||||
className={p.badge || row ? "btn btn-primary" : "btn"}
|
||||
onClick={() => buy(p)}
|
||||
disabled={busy !== null}
|
||||
>
|
||||
{busy === p.id ? (canPay === "mock" ? "Fizetés…" : "Átirányítás…") : "Megveszem"}
|
||||
</button>
|
||||
) : (
|
||||
<button type="button" className="btn" disabled>
|
||||
Hamarosan
|
||||
</button>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="field" style={{ gap: 12 }}>
|
||||
<div className={compact ? "pkg-grid pkg-grid-compact" : "pkg-grid"}>
|
||||
{shown.map((p, i) => {
|
||||
const prev = i > 0 ? shown[i - 1] : null;
|
||||
const step = prev && p.tier === "main" && prev.tier === "main" ? p.price_huf - prev.price_huf : null;
|
||||
return (
|
||||
<article key={p.id} className={p.badge ? "pkg pkg-featured" : "pkg"} aria-labelledby={`pkg-${p.id}`}>
|
||||
<div className="pkg-tags">
|
||||
{p.badge && <span className="pkg-badge">{p.badge}</span>}
|
||||
{p.savings_percent ? <span className="pkg-save">−{p.savings_percent}%</span> : null}
|
||||
{row ? (
|
||||
<div className="pkg-rows">
|
||||
{shown.map((p) => (
|
||||
<div key={p.id} className="pkg-row">
|
||||
<div className="pkg-row-text">
|
||||
<strong>{p.name}</strong>
|
||||
<span className="num">{huf(p.price_huf)}</span>
|
||||
</div>
|
||||
<h3 id={`pkg-${p.id}`} className="pkg-name">
|
||||
{p.name}
|
||||
</h3>
|
||||
{!compact && <p className="muted pkg-tagline">{p.tagline}</p>}
|
||||
<div className="pkg-price">
|
||||
<strong>{huf(p.price_huf)}</strong>
|
||||
{p.list_price_huf > p.price_huf && (
|
||||
<s className="hint" aria-label={`Külön megvéve ${huf(p.list_price_huf)}`}>
|
||||
{huf(p.list_price_huf)}
|
||||
</s>
|
||||
)}
|
||||
</div>
|
||||
<ul className="pkg-list">
|
||||
{contents(p).map((line) => (
|
||||
<li key={line}>{line}</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="hint pkg-per">
|
||||
{p.per_analysis_huf ? `Elemzésenként ${huf(p.per_analysis_huf)}` : " "}
|
||||
</p>
|
||||
{step !== null && step > 0 && prev && (
|
||||
<p className="pkg-step">
|
||||
Csak +{huf(step)} a(z) {prev.name} csomaghoz képest
|
||||
{buyButton(p)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className={compact ? "pkg-grid pkg-grid-compact" : "pkg-grid"}>
|
||||
{shown.map((p, i) => {
|
||||
const prev = i > 0 ? shown[i - 1] : null;
|
||||
const step = prev && p.tier === "main" && prev.tier === "main" ? p.price_huf - prev.price_huf : null;
|
||||
return (
|
||||
<article key={p.id} className={p.badge ? "pkg pkg-featured" : "pkg"} aria-labelledby={`pkg-${p.id}`}>
|
||||
<div className="pkg-tags">
|
||||
{p.badge && <span className="pkg-badge">{p.badge}</span>}
|
||||
{p.savings_percent ? <span className="pkg-save">−{p.savings_percent}%</span> : null}
|
||||
</div>
|
||||
<h3 id={`pkg-${p.id}`} className="pkg-name">
|
||||
{p.name}
|
||||
</h3>
|
||||
{!compact && <p className="muted pkg-tagline">{p.tagline}</p>}
|
||||
<div className="pkg-price">
|
||||
<strong>{huf(p.price_huf)}</strong>
|
||||
{p.list_price_huf > p.price_huf && (
|
||||
<s className="hint" aria-label={`Külön megvéve ${huf(p.list_price_huf)}`}>
|
||||
{huf(p.list_price_huf)}
|
||||
</s>
|
||||
)}
|
||||
</div>
|
||||
<ul className="pkg-list">
|
||||
{contents(p).map((line) => (
|
||||
<li key={line}>{line}</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="hint pkg-per">
|
||||
{p.per_analysis_huf ? `Elemzésenként ${huf(p.per_analysis_huf)}` : " "}
|
||||
</p>
|
||||
)}
|
||||
{canPay ? (
|
||||
<button
|
||||
type="button"
|
||||
className={p.badge ? "btn btn-primary" : "btn"}
|
||||
onClick={() => buy(p)}
|
||||
disabled={busy !== null}
|
||||
>
|
||||
{busy === p.id ? (canPay === "mock" ? "Fizetés…" : "Átirányítás…") : "Megveszem"}
|
||||
</button>
|
||||
) : (
|
||||
<button type="button" className="btn" disabled>
|
||||
Hamarosan
|
||||
</button>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{step !== null && step > 0 && prev && (
|
||||
<p className="pkg-step">
|
||||
Csak +{huf(step)} a(z) {prev.name} csomaghoz képest
|
||||
</p>
|
||||
)}
|
||||
{buyButton(p)}
|
||||
</article>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
@@ -187,17 +207,20 @@ export function usePackages(): Package[] | null {
|
||||
export function PackageChooser({
|
||||
ids,
|
||||
canPay,
|
||||
row = false,
|
||||
onBought,
|
||||
}: {
|
||||
ids: string[];
|
||||
canPay: PayMethod | null;
|
||||
/** One line per package (see PackageCards). */
|
||||
row?: boolean;
|
||||
onBought?: (p: Package) => Promise<void> | void;
|
||||
}) {
|
||||
const packages = usePackages();
|
||||
if (packages === null) return <p className="muted">Csomagok betöltése…</p>;
|
||||
return (
|
||||
<div className="field" style={{ gap: 8 }}>
|
||||
<PackageCards packages={packages} ids={ids} canPay={canPay} compact onBought={onBought} />
|
||||
<PackageCards packages={packages} ids={ids} canPay={canPay} compact row={row} onBought={onBought} />
|
||||
<Link href="/csomagok" className="hint">
|
||||
Összes csomag és a részletek →
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user