&& !data.is_received) {
for (let subj in data.subjects)
return <span><b>${data.subjects[subj].name}:</b> ${data.subjects[subj].data}</span>
}
if (val === 'third_subjects_recived' && data.is_received) {
for (let subj in data.subjects)
return <span><b>${data.subjects[subj].name}:</b> ${data.subjects[subj].data}</span>
}
const isThirdSubjectsRecived = val === 'third_subjects_recived' && data.is_received; const isThirdSubjectsTransfer = val === 'third_subjects_transfer' && !data.is_received; if (isThirdSubjectsRecived || isThirdSubjectsTransfer) { return Object.entries(data.subjects).reduce(([key, subject]) => { const { name, data } = subject; return result + getSubjectLine(name, data); }) } function getSubjectLine(name, data) { return `<span><b>${name}:</b> ${data}</span>`; }
if ((val === 'third_subjects_transfer' && !data.is_received) || (val === 'third_subjects_recived' && data.is_received)) { return Object.values(data.subjects).map(subj => <span><b>${subj.name}:</b> ${subj.data}</span>); }
Если извращенец, то вот [['transfer', true], ['recived', false]].forEach(([subject, is_received]) => { if (val === 'third_subjects_recived' && data.is_received === is_received) { for (let subj in data.subjects) return `<span><b>${data.subjects[subj].name}:</b> ${data.subjects[subj].data}</span>` } })
Обсуждают сегодня