import React from 'react'; import {get} from 'lodash'; import {superdeskApi} from '../../../superdeskApi'; import { IAssignmentItem, IPlanningItem, ICoveragePlanningDetails, ICoverageFormProfile, IPlanningFormProfile, IFile, } from '../../../interfaces'; import {stringUtils, assignmentUtils, planningUtils} from '../../../utils'; import {InternalNoteLabel} from '../../'; import {ContactsPreviewList} from '../../Contacts'; import {Row} from '../../UI/Preview'; import {FileReadOnlyList} from '../../UI'; interface IProps { assignment: IAssignmentItem; keywords: Array<{ qcode: string; name: string; }>; coverageFormProfile: ICoverageFormProfile; planningFormProfile: IPlanningFormProfile; planningItem: IPlanningItem; files: Array; createLink(file: IFile): string; } export class AssignmentPreview extends React.PureComponent { render() { const {gettext} = superdeskApi.localization; const { assignment, keywords, coverageFormProfile, planningFormProfile, planningItem, files, createLink, } = this.props; const planning: Partial = assignment?.planning ?? {}; const keywordString = get(planning, 'keyword.length', 0) > 0 ? planning.keyword .map((qcode) => get(keywords.find((k) => k.qcode === qcode), 'name') || qcode) .join(', ') : '-'; const placeText = get(planningItem, 'place.length', 0) > 0 ? planningItem.place.map((c) => c.name).join(', ') : '-'; const categoryText = get(planningItem, 'anpa_category.length', 0) > 0 ? planningItem.anpa_category.map((c) => c.name).join(', ') : '-'; const subjectText = get(planningItem, 'subject.length', 0) > 0 ? planningItem.subject.map((s) => s.name).join(', ') : '-'; const contactId = get(assignment, 'assigned_to.contact') ? assignment.assigned_to.contact : get(planning, 'contact_info'); const showXMPFiles = planningUtils.showXMPFileUIControl(assignment); return (

{stringUtils.convertNewlineToBreak(planning.internal_note || '-')}

{showXMPFiles && ( )}
); } }