Files
X4Lo 1f1d28a34d Add B1 Meister: OeSD B1 exam trainer (German-Arabic)
Next.js app with Hoeren, Lesen, Schreiben, Sprechen, Grammatik and Wortschatz sections, flashcards with spaced repetition, speaking chat, XP/streaks/badges, daily reminders (PWA) and Docker Compose setup for Coolify.
2026-11-05 19:11:46 +00:00

45 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect } from "react";
import { fireConfetti } from "./AppShell";
import { sfx } from "@/lib/sfx";
export function scoreMessage(pct: number) {
if (pct === 100) return { emoji: "🏆", de: "Perfekt! Du bist bereit für die Prüfung!", ar: "ممتاز! أنت جاهز للامتحان!" };
if (pct >= 80) return { emoji: "🌟", de: "Sehr gut! Weiter so!", ar: "جيد جداً! استمر هكذا!" };
if (pct >= 60) return { emoji: "👍", de: "Bestanden! (60 % reichen in der Prüfung)", ar: "ناجح! (60% تكفي في الامتحان)" };
return { emoji: "💪", de: "Noch nicht ganz – versuch es noch einmal!", ar: "ليس بعد – حاول مرة أخرى!" };
}
export default function ResultCard({ correct, total, xp, onRetry, children }: { correct: number; total: number; xp: number; onRetry?: () => void; children?: React.ReactNode }) {
const pct = total ? Math.round((correct / total) * 100) : 0;
const m = scoreMessage(pct);
useEffect(() => {
if (pct >= 80) {
fireConfetti();
sfx.win();
}
}, [pct]);
return (
<div className="card fade-in" style={{ marginTop: 16, textAlign: "center", borderColor: pct >= 60 ? "var(--green)" : "var(--orange)" }}>
<div style={{ fontSize: 52 }}>{m.emoji}</div>
<div style={{ fontSize: 30, fontWeight: 900 }}>
{correct} / {total} <span className="muted" style={{ fontSize: 18 }}>({pct} %)</span>
</div>
<div style={{ fontWeight: 800, marginTop: 4 }}>{m.de}</div>
<div className="ar muted">{m.ar}</div>
<div className="pill purple" style={{ marginTop: 8 }}>
+{xp} XP
</div>
{children}
{onRetry && (
<div style={{ marginTop: 14 }}>
<button type="button" className="btn secondary" onClick={onRetry}>
🔁 Nochmal
</button>
</div>
)}
</div>
);
}