Abo-Bereich visuell auf Premium-Niveau gehoben

Plan-Karten: eigenes Icon je Stufe (🌱/🌿/👑), Rabatt als farbiger Chip statt
reinem Fließtext, Prämien-Intervalle als eigene Chips (aus den admin-
konfigurierten Werten berechnet), Preis mit Farbverlauf, sanft pulsierender
Rahmen für die aktuell gebuchte Stufe.

Abo-Status: Tabelle durch ein Stat-Kachel-Raster ersetzt (Icon + Label + Wert
pro Kennzahl, Rabatt farblich hervorgehoben), echte Fortschrittsbalken statt
Text für den Weg zum nächsten Teddy (Prozent aus dem admin-konfigurierten
Intervall berechnet), "Bereits erhalten" als Badge-Chip, verfügbare Prämien
als eigene, leicht glühende Karten statt schlichter Buttons.

Benachrichtigungen: farbiger Icon-Kreis pro Ereignistyp (Erfolg/Prämie/
Warnung/Abbruch/Info) statt einheitlicher grauer Liste — auf einen Blick
erkennbar, worum es bei jedem Eintrag geht.

Alles in 4 Sprachen (DE/EN/CH/FR), neues i18n-Template aboRewardEveryLabel
für die Prämien-Intervall-Chips.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
qcigano
2026-08-03 17:49:24 +02:00
co-authored by Claude Sonnet 5
parent 28ded7faae
commit 2c6d4dedae
6 changed files with 695 additions and 144 deletions
+137 -33
View File
@@ -58,6 +58,9 @@ const aboPlanLabels: Record<AboStufe, { name: string; vorteil: string }> = {
mittel: { name: aboStufeName("mittel", lang), vorteil: aboStufeVorteil("mittel", lang) },
gross: { name: aboStufeName("gross", lang), vorteil: aboStufeVorteil("gross", lang) },
};
// Eigenes Icon je Stufe (rein optisch, nicht admin-editierbar) — soll auf einen Blick erkennbar
// machen, dass es sich um eine aufsteigende Reihe handelt (Keimling → Blatt → Krone).
const aboPlanIcon: Record<AboStufe, string> = { klein: "🌱", mittel: "🌿", gross: "👑" };
// "Zuletzt angesehen" zeigt in dieser Vorschau einfach die ersten echten Produkte aus dem Shop —
// in Phase 2 kommt hier die tatsächliche Verlaufs-Historie der angemeldeten Person hin.
@@ -360,8 +363,18 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
return (
<div class={`card abo-plan-card abo-plan-${stufe}`} data-abo-plan={stufe} data-abo-plan-aktiv={cfg.aktiv ? "1" : "0"}>
<span class="abo-plan-badge" data-abo-active-badge style="display:none;">{t.accountDash.aboAktivesLabel}</span>
<span class="abo-plan-icon" aria-hidden="true">{aboPlanIcon[stufe]}</span>
<h3>{labels.name}</h3>
<p class="abo-plan-price">{formatPrice(cfg.preis, lang)} <span class="small">{t.accountDash.aboPreisSuffix}</span></p>
<span class="abo-plan-discount-chip">💰 {cfg.rabattProzent}%</span>
<div class="abo-plan-rewards">
{cfg.kleinIntervallMonate > 0 && (
<span class="abo-plan-reward-chip">🧸 {t.accountDash.aboRewardEveryLabel.replace("{n}", String(cfg.kleinIntervallMonate))}</span>
)}
{cfg.grossIntervallMonate > 0 && (
<span class="abo-plan-reward-chip abo-plan-reward-chip-gross">🧸🧸 {t.accountDash.aboRewardEveryLabel.replace("{n}", String(cfg.grossIntervallMonate))}</span>
)}
</div>
<p class="small abo-plan-vorteil">{labels.vorteil}</p>
<button type="button" class="btn btn-primary btn-sm abo-plan-btn" data-abo-choose={stufe}>{t.accountDash.aboAbschliessenBtn}</button>
</div>
@@ -373,28 +386,81 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
<span class="loyalty-card-sparkle loyalty-card-sparkle-1" aria-hidden="true">✨</span>
<span class="loyalty-card-sparkle loyalty-card-sparkle-2" aria-hidden="true">✨</span>
<h3>{t.accountDash.aboStatusTitle} <span class="badge" id="abo-active-badge"></span></h3>
<table class="specs">
<tbody>
<tr><th>{t.accountDash.aboFieldStufe}</th><td id="abo-field-stufe"></td></tr>
<tr><th>{t.accountDash.aboFieldPreis}</th><td id="abo-field-preis"></td></tr>
<tr><th>{t.accountDash.aboFieldRabatt}</th><td id="abo-field-rabatt"></td></tr>
<tr><th>{t.accountDash.aboFieldStart}</th><td id="abo-field-start"></td></tr>
<tr><th>{t.accountDash.aboFieldNaechsteZahlung}</th><td id="abo-field-naechste"></td></tr>
<tr><th>{t.accountDash.aboFieldLaufzeit}</th><td id="abo-field-laufzeit"></td></tr>
</tbody>
</table>
<p id="abo-fortschritt-klein" style="display:none;"></p>
<p id="abo-fortschritt-gross" style="display:none;"></p>
<p id="abo-praemien-erhalten"></p>
<div class="abo-stat-grid">
<div class="abo-stat-tile">
<span class="abo-stat-icon" aria-hidden="true">🎫</span>
<span class="abo-stat-label">{t.accountDash.aboFieldStufe}</span>
<span class="abo-stat-value" id="abo-field-stufe"></span>
</div>
<div class="abo-stat-tile">
<span class="abo-stat-icon" aria-hidden="true">💶</span>
<span class="abo-stat-label">{t.accountDash.aboFieldPreis}</span>
<span class="abo-stat-value" id="abo-field-preis"></span>
</div>
<div class="abo-stat-tile abo-stat-tile-highlight">
<span class="abo-stat-icon" aria-hidden="true">💰</span>
<span class="abo-stat-label">{t.accountDash.aboFieldRabatt}</span>
<span class="abo-stat-value" id="abo-field-rabatt"></span>
</div>
<div class="abo-stat-tile">
<span class="abo-stat-icon" aria-hidden="true">📅</span>
<span class="abo-stat-label">{t.accountDash.aboFieldStart}</span>
<span class="abo-stat-value" id="abo-field-start"></span>
</div>
<div class="abo-stat-tile">
<span class="abo-stat-icon" aria-hidden="true">🔁</span>
<span class="abo-stat-label">{t.accountDash.aboFieldNaechsteZahlung}</span>
<span class="abo-stat-value" id="abo-field-naechste"></span>
</div>
<div class="abo-stat-tile">
<span class="abo-stat-icon" aria-hidden="true">⏱️</span>
<span class="abo-stat-label">{t.accountDash.aboFieldLaufzeit}</span>
<span class="abo-stat-value" id="abo-field-laufzeit"></span>
</div>
</div>
<div class="abo-reward-progress-block">
<div class="abo-reward-progress" id="abo-fortschritt-klein-wrap" style="display:none;">
<div class="abo-reward-progress-head">
<span>🧸 {t.accountDash.aboEinloesenKleinLabel}</span>
<span id="abo-fortschritt-klein-text"></span>
</div>
<div class="loyalty-progress-bar abo-reward-bar"><div class="loyalty-progress-fill" id="abo-fortschritt-klein-fill"></div></div>
</div>
<div class="abo-reward-progress" id="abo-fortschritt-gross-wrap" style="display:none;">
<div class="abo-reward-progress-head">
<span>🧸🧸 {t.accountDash.aboEinloesenGrossLabel}</span>
<span id="abo-fortschritt-gross-text"></span>
</div>
<div class="loyalty-progress-bar abo-reward-bar"><div class="loyalty-progress-fill abo-reward-bar-gross" id="abo-fortschritt-gross-fill"></div></div>
</div>
</div>
<div class="abo-erhalten-chip">
<span aria-hidden="true">🧸</span>
<span id="abo-praemien-erhalten"></span>
</div>
<p id="abo-gekuendigt-hinweis" class="small" style="display:none;"></p>
<div class="abo-praemien-block">
<h4>{t.accountDash.aboPraemienVerfuegbarTitle}</h4>
<p class="small" id="abo-keine-praemien">{t.accountDash.aboKeinePraemienVerfuegbar}</p>
<div class="abo-praemien-row">
<button type="button" class="btn btn-outline btn-sm" id="abo-einloesen-klein" style="display:none;" data-einloesen="klein">🧸 {t.accountDash.aboEinloesenKleinLabel} — {t.accountDash.aboEinloesenBtn}</button>
<button type="button" class="btn btn-outline btn-sm" id="abo-einloesen-gross" style="display:none;" data-einloesen="gross">🧸 {t.accountDash.aboEinloesenGrossLabel} — {t.accountDash.aboEinloesenBtn}</button>
<div class="abo-reward-ready" id="abo-einloesen-klein-wrap" style="display:none;">
<span class="abo-reward-ready-icon" aria-hidden="true">🧸</span>
<div class="abo-reward-ready-body">
<strong>{t.accountDash.aboEinloesenKleinLabel}</strong>
<button type="button" class="btn btn-primary btn-sm" id="abo-einloesen-klein" data-einloesen="klein">{t.accountDash.aboEinloesenBtn}</button>
</div>
</div>
<div class="abo-reward-ready" id="abo-einloesen-gross-wrap" style="display:none;">
<span class="abo-reward-ready-icon" aria-hidden="true">🧸</span>
<div class="abo-reward-ready-body">
<strong>{t.accountDash.aboEinloesenGrossLabel}</strong>
<button type="button" class="btn btn-primary btn-sm" id="abo-einloesen-gross" data-einloesen="gross">{t.accountDash.aboEinloesenBtn}</button>
</div>
</div>
</div>
<p class="small" id="abo-eingeloest-hinweis" style="display:none; color: var(--c-accent);">{t.accountDash.aboEingeloestHinweis}</p>
</div>
@@ -514,6 +580,7 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
import { rechnungAlsPdfHerunterladen } from "../../scripts/invoice-pdf";
import { fuegeTeddyGratisHinzu } from "../../scripts/cart";
import { formatPrice } from "../../i18n/format";
import { aboStufenKonfig } from "../../data/abo";
const { loginPath, fallbackName, greetingTemplate, reviewedBadgeText, invoiceLang, invoiceLabels, loyaltyProgressTemplate, loyaltyRemainingOne, loyaltyRemainingOther, loyaltyUnlockedTitle, loyaltyUnlockedText, aboLang, aboLabels } = (window as any).__accountDashVars;
// Zugriffsschutz: diese Seite ist nur für angemeldete Kund:innen gedacht. Es gibt noch kein
@@ -605,6 +672,30 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
// Abosystem: Pläne, Status, Fortschritt, Prämien und Benachrichtigungen live aus dem Konto
// rendern (Nav-Kachel + Planvergleich + Statuskarte + Benachrichtigungsliste).
const aboNameMap: Record<string, string> = { klein: aboLabels.nameKlein, mittel: aboLabels.nameMittel, gross: aboLabels.nameGross };
// Icon + Farbkategorie je Benachrichtigungs-Typ — rein optisch, keine Übersetzung nötig
// (die Schlüssel sind sprachneutrale Konstanten aus scripts/account.ts).
const NOTIF_ICON: Record<string, string> = {
abo_abgeschlossen: "🎉",
abo_gewechselt: "🔄",
abo_zahlung_erfolgreich: "✅",
abo_teddy_klein_frei: "🧸",
abo_teddy_gross_frei: "🧸",
abo_bald_praemie: "⏳",
abo_gekuendigt: "🚫",
abo_teddy_klein_eingeloest: "🎁",
abo_teddy_gross_eingeloest: "🎁",
};
const NOTIF_KATEGORIE: Record<string, string> = {
abo_abgeschlossen: "erfolg",
abo_gewechselt: "info",
abo_zahlung_erfolgreich: "erfolg",
abo_teddy_klein_frei: "praemie",
abo_teddy_gross_frei: "praemie",
abo_bald_praemie: "warnung",
abo_gekuendigt: "abbruch",
abo_teddy_klein_eingeloest: "praemie",
abo_teddy_gross_eingeloest: "praemie",
};
function renderAbo() {
const a = getAccount();
@@ -655,19 +746,28 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
activeBadge.className = "badge " + (status.aktiv ? "abo-badge-active" : "abo-badge-inactive");
}
const fortschrittKlein = document.getElementById("abo-fortschritt-klein");
if (fortschrittKlein) {
if (status.naechsterKleinIn != null) {
fortschrittKlein.style.display = "block";
fortschrittKlein.textContent = aboLabels.fortschrittKleinTemplate.replace("{n}", String(status.naechsterKleinIn));
} else fortschrittKlein.style.display = "none";
// Echte Fortschrittsbalken statt reinem Text — Prozent ergibt sich aus dem admin-
// konfigurierten Intervall (aboStufenKonfig) minus der noch fehlenden Monate.
const stufenKonfig = aboStufenKonfig(status.stufe);
const fortschrittKleinWrap = document.getElementById("abo-fortschritt-klein-wrap");
if (fortschrittKleinWrap) {
if (status.naechsterKleinIn != null && stufenKonfig.kleinIntervallMonate > 0) {
fortschrittKleinWrap.style.display = "block";
setText("abo-fortschritt-klein-text", aboLabels.fortschrittKleinTemplate.replace("{n}", String(status.naechsterKleinIn)));
const pct = Math.min(100, Math.max(0, ((stufenKonfig.kleinIntervallMonate - status.naechsterKleinIn) / stufenKonfig.kleinIntervallMonate) * 100));
const fill = document.getElementById("abo-fortschritt-klein-fill") as HTMLElement | null;
if (fill) fill.style.width = `${pct}%`;
} else fortschrittKleinWrap.style.display = "none";
}
const fortschrittGross = document.getElementById("abo-fortschritt-gross");
if (fortschrittGross) {
if (status.naechsterGrossIn != null) {
fortschrittGross.style.display = "block";
fortschrittGross.textContent = aboLabels.fortschrittGrossTemplate.replace("{n}", String(status.naechsterGrossIn));
} else fortschrittGross.style.display = "none";
const fortschrittGrossWrap = document.getElementById("abo-fortschritt-gross-wrap");
if (fortschrittGrossWrap) {
if (status.naechsterGrossIn != null && stufenKonfig.grossIntervallMonate > 0) {
fortschrittGrossWrap.style.display = "block";
setText("abo-fortschritt-gross-text", aboLabels.fortschrittGrossTemplate.replace("{n}", String(status.naechsterGrossIn)));
const pct = Math.min(100, Math.max(0, ((stufenKonfig.grossIntervallMonate - status.naechsterGrossIn) / stufenKonfig.grossIntervallMonate) * 100));
const fill = document.getElementById("abo-fortschritt-gross-fill") as HTMLElement | null;
if (fill) fill.style.width = `${pct}%`;
} else fortschrittGrossWrap.style.display = "none";
}
setText("abo-praemien-erhalten", aboLabels.praemienErhaltenTemplate
@@ -684,11 +784,11 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
const hasKlein = status.kleinVerfuegbar > 0;
const hasGross = status.grossVerfuegbar > 0;
const einloesenKlein = document.getElementById("abo-einloesen-klein") as HTMLElement | null;
const einloesenGross = document.getElementById("abo-einloesen-gross") as HTMLElement | null;
const einloesenKleinWrap = document.getElementById("abo-einloesen-klein-wrap") as HTMLElement | null;
const einloesenGrossWrap = document.getElementById("abo-einloesen-gross-wrap") as HTMLElement | null;
const keinePraemien = document.getElementById("abo-keine-praemien") as HTMLElement | null;
if (einloesenKlein) einloesenKlein.style.display = hasKlein ? "inline-flex" : "none";
if (einloesenGross) einloesenGross.style.display = hasGross ? "inline-flex" : "none";
if (einloesenKleinWrap) einloesenKleinWrap.style.display = hasKlein ? "flex" : "none";
if (einloesenGrossWrap) einloesenGrossWrap.style.display = hasGross ? "flex" : "none";
if (keinePraemien) keinePraemien.style.display = hasKlein || hasGross ? "none" : "block";
const kuendigenBtn = document.getElementById("abo-kuendigen-btn") as HTMLElement | null;
@@ -706,10 +806,14 @@ const angekommeneBestellungen = beispielBestellungen.filter((b) => b.status ===
} else {
a.benachrichtigungen.forEach((n) => {
const li = document.createElement("li");
li.className = "small abo-notif-item" + (n.gelesen ? "" : " abo-notif-unread");
const kategorie = NOTIF_KATEGORIE[n.key] ?? "info";
li.className = `abo-notif-item abo-notif-${kategorie}` + (n.gelesen ? "" : " abo-notif-unread");
let text = aboLabels.notifKeyLabels[n.key] ?? n.key;
if (n.stufe) text = text.replace("{stufe}", aboNameMap[n.stufe] ?? n.stufe);
li.textContent = `${n.datum} — ${text}`;
li.innerHTML = `
<span class="abo-notif-icon" aria-hidden="true">${NOTIF_ICON[n.key] ?? "🔔"}</span>
<span class="abo-notif-body"><span class="abo-notif-text small">${text}</span><span class="abo-notif-date small">${n.datum}</span></span>
`;
list.appendChild(li);
});
}