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.
50 lines (38 loc) • 1.21 kB
JSX
import React, { Component } from 'react';
export const hasFoundIn = (entity) => {
  return (entity.data.uris || entity.data.discoveryDate);
};
export class EntityFoundIn extends Component {
  render() {
    const { entity } = this.props;
    let location;
    let dateContent;
    if (entity.data.uris) {
      const uris = entity.data.uris.filter((uri) => {
        return uri.origin;
      });
      if (uris.length === 1) {
        location = (
          <span>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} </span>);
          }
          return (<span key={index}>{link}, </span>);
        });
        location = (<span>in {locations}</span>);
      }
    }
    if (entity.data.discoveryDate) {
      dateContent = (<span>{entity.data.discoveryDate}</span>);
    }
    if (!dateContent && !location) {
      return (<span></span>);
    }
    return (<div>Found {location} {dateContent}</div>);
  }
}