UNPKG

cluedin-widget

Version:

This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.

73 lines (56 loc) 1.72 kB
import React, { Component } from 'react'; export const hasCreatedBy = (entity) => { return entity.data.authors; }; export class EntityLastCreatedBy extends Component { render() { const { entity } = this.props; let location; if (entity.data.uris) { const uris = entity.data.uris.filter((uri) => { return uri.origin; }); if (uris.length === 1) { location = ( <span>&nbsp;in <a href={entity.data.uris[0].uri}>{entity.data.uris[0].origin}</a></span> ); } if (uris.length > 1) { let locations = uris.map((uri, index) => { let link = (<a href={uri.uri}>{uri.origin}</a>); if (index === (uris.length -1)) { return (<span key={index}>{link}&nbsp;</span>); } return (<span key={index}>{link},&nbsp;</span>); }); location = (<span>in {locations}</span>); } } if (entity.data.authors) { let authorsWithName = entity.data.authors.filter((a) => { return a.name; }); let createdByAuthor = authorsWithName.map((a, index) => { if (index !== (authorsWithName.length - 1)) { return (<span key={index}>{a.name},&nbsp;</span>); } return (<span key={index}>{a.name}</span>); }); let createdByDateContent; if (entity.data.createdDateFormatted) { createdByDateContent = (<span>&nbsp;{entity.data.createdDateFormatted}</span>); } return ( <div> <span> Created by&nbsp; </span> {createdByAuthor} {location} {createdByDateContent} </div> ); } return (<span></span>); } }