fix: Review-Modal pro answer_type korrekt anzeigen

- word: 'Positiv-Wörter' / 'Negativ-Wörter' (statt irreführendem Satz-Feld)
- yes_no: Ja/Nein-Antwort als Einzelwert statt leerem Satz
- text/question: Sätze wie bisher

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 21:01:36 +02:00
parent ae94721466
commit 4fd9c3c4e4

View File

@@ -16,39 +16,45 @@ function strip(text) {
});
}
// Baut die Anzeigezeilen (Frage / Positiv / Negativ) aus dem content-Bündel.
// Baut die Anzeigezeilen je nach answer_type. Jede Zeile ist entweder
// - { kind: 'lang', label, color, cell(l) } → eine Zelle pro Sprache (übersetzbar)
// - { kind: 'single', label, color, value } → ein einzelner Wert (nicht sprachabhängig)
function buildRows(content) {
if (!content) return [];
const type = content?.answer_type;
const rows = [];
const isWord = content.answer_type === 'word';
const wordsCell = (stmt) => (l) =>
(stmt?.words || []).map(w => w[`titel_${l}`] || '—').join(', ');
const sentenceCell = (stmt, prefix) => (l) =>
strip(stmt?.sentence?.[`${prefix}_${l}`] || '');
// Frage (yes_no / question / word)
if (content.question) {
rows.push({
label: 'Frage', color: 'text-slate-700',
cell: l => strip(content.question[`sentence_${l}`] || ''),
});
rows.push({ kind: 'lang', label: 'Frage', color: 'text-slate-700',
cell: l => strip(content.question[`sentence_${l}`] || '') });
}
if (content.positive) {
rows.push({
label: 'Positiv', color: 'text-green-700',
cell: l => isWord
? content.positive.words.map(w => w[`titel_${l}`] || '—').join(', ')
: strip(content.positive.sentence[`positive_sentence_${l}`] || ''),
});
}
// Negativ nur zeigen, wenn überhaupt Inhalt vorhanden ist
const negHasContent = content.negative && (
content.answer_type === 'word'
? content.negative.words.length > 0
: LANGS.some(l => (content.negative.sentence[`negative_sentence_${l}`] || '').trim())
);
if (negHasContent) {
rows.push({
label: 'Negativ', color: 'text-red-600',
cell: l => isWord
? content.negative.words.map(w => w[`titel_${l}`] || '').join(', ')
: strip(content.negative.sentence[`negative_sentence_${l}`] || ''),
});
if (type === 'yes_no') {
// Ja/Nein-Antwort ist ein boolescher Wert, keine Übersetzung
const a = content.positive?.answer;
rows.push({ kind: 'single', label: 'Antwort', color: 'text-green-700',
value: a === true ? '✓ Ja' : a === false ? '✗ Nein' : null });
} else if (type === 'word') {
rows.push({ kind: 'lang', label: 'Positiv-Wörter', color: 'text-green-700',
cell: wordsCell(content.positive) });
if (content.negative?.words?.length)
rows.push({ kind: 'lang', label: 'Negativ-Wörter', color: 'text-red-600',
cell: wordsCell(content.negative) });
} else {
// text / question → Sätze
if (content.positive)
rows.push({ kind: 'lang', label: 'Positiv', color: 'text-green-700',
cell: sentenceCell(content.positive, 'positive_sentence') });
const negHasContent = content.negative &&
LANGS.some(l => (content.negative.sentence?.[`negative_sentence_${l}`] || '').trim());
if (negHasContent)
rows.push({ kind: 'lang', label: 'Negativ', color: 'text-red-600',
cell: sentenceCell(content.negative, 'negative_sentence') });
}
return rows;
}
@@ -98,7 +104,7 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) {
{/* Body — Übersetzungen zum Gegenprüfen */}
<div className="px-6 py-5 overflow-y-auto">
<div className="grid gap-3" style={{ gridTemplateColumns: '5rem repeat(3, 1fr)' }}>
<div className="grid gap-3 items-center" style={{ gridTemplateColumns: '7rem repeat(3, 1fr)' }}>
<div />
{LANGS.map(l => (
<div key={l.code} className="text-center text-sm font-medium text-slate-500">{l.flag} {l.code.toUpperCase()}</div>
@@ -108,7 +114,7 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) {
))}
</div>
{rows.length === 0 && (
<p className="text-sm text-slate-400 text-center py-6">Kein übersetzbarer Inhalt gefunden.</p>
<p className="text-sm text-slate-400 text-center py-6">Kein Inhalt gefunden.</p>
)}
</div>
@@ -141,9 +147,19 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) {
}
function Row({ row }) {
if (row.kind === 'single') {
return (
<>
<div className="text-xs font-semibold text-slate-400 self-center">{row.label}</div>
<div className="text-xs font-semibold text-slate-400">{row.label}</div>
<div className={`col-span-3 text-sm rounded-lg border px-2.5 py-1.5 ${row.value ? `bg-slate-50 border-slate-200 ${row.color}` : 'bg-red-50 border-red-200 text-red-400 italic'}`}>
{row.value || 'fehlt'}
</div>
</>
);
}
return (
<>
<div className="text-xs font-semibold text-slate-400">{row.label}</div>
{LANGS.map(l => {
const val = row.cell(l.code);
return (