diff --git a/src/components/PairReviewModal.jsx b/src/components/PairReviewModal.jsx index 2b59744..2c8924a 100644 --- a/src/components/PairReviewModal.jsx +++ b/src/components/PairReviewModal.jsx @@ -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 */}
-
+
{LANGS.map(l => (
{l.flag} {l.code.toUpperCase()}
@@ -108,7 +114,7 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) { ))}
{rows.length === 0 && ( -

Kein übersetzbarer Inhalt gefunden.

+

Kein Inhalt gefunden.

)}
@@ -141,9 +147,19 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) { } function Row({ row }) { + if (row.kind === 'single') { + return ( + <> +
{row.label}
+
+ {row.value || 'fehlt'} +
+ + ); + } return ( <> -
{row.label}
+
{row.label}
{LANGS.map(l => { const val = row.cell(l.code); return (