From a8cfefc602a43753353940816633daae3e1692aa Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 28 Mar 2019 16:25:23 +0100 Subject: abstract into citationList component --- scraper/client/paper/citationList.component.js | 96 ++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 scraper/client/paper/citationList.component.js (limited to 'scraper/client/paper/citationList.component.js') diff --git a/scraper/client/paper/citationList.component.js b/scraper/client/paper/citationList.component.js new file mode 100644 index 00000000..435dfde2 --- /dev/null +++ b/scraper/client/paper/citationList.component.js @@ -0,0 +1,96 @@ +import React, { Component } from 'react' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { Link } from 'react-router-dom' + +import * as actions from '../actions' + +import { TableObject, Loader } from '../common' +import { USES_DATASET } from '../types' + +class CitationList extends Component { + render() { + const { citations, title, api } = this.props + const { paperInfo, unknownCitations, verifications } = api + const { dataset } = paperInfo + if (!dataset || !citations || !verifications[dataset.key]) return + let verifiedLookup = verifications[dataset.key] || {} + // console.log(verifications) + + return ( +
+

{title}

+
    + {citations + .map(citation => [citation.title, verifiedLookup[citation.id] ? verifiedLookup[citation.id].uses_dataset : USES_DATASET.UNKNOWN, citation]) + .sort((a,b) => (b[1] - a[1] || (a[0].localeCompare(b[0])))) + .map((pair, i) => { + const [ title, uses_dataset, citation ] = pair + let cite = { ...citation } + cite.id = { + _raw: true, + value: {citation.id} + } + cite.pdf = { + _raw: true, + value: (cite.pdf && cite.pdf.length) + ? cite.pdf.map((pdf, i) => [pdf]) + : "no pdf" + } + cite.s2 = { + _raw: true, + value: {'[semantic scholar]'} + } + cite.addresses = { + _raw: true, + value: (cite.addresses || []).map((address, j) => ( +
    {address.name}{', '}{address.type}
    + )) + } + if (citation.id in verifiedLookup) { + const verification = verifiedLookup[citation.id] + cite.verified = { + _raw: true, + value: verification.uses_dataset === USES_DATASET.YES + ? uses dataset + : verification.uses_dataset === USES_DATASET.NO + ? {"doesn't use dataset"} + : {"not enough information"} + } + } + else { + cite.verified = { + _raw: true, + value: unknown + } + } + return ( +
  • + +
  • + ) + })} +
+
+ ) + } +} + +const mapStateToProps = state => ({ + api: state.api +}) +const mapDispatchToProps = dispatch => ({ + actions: bindActionCreators({ ...actions }, dispatch), +}) + +export default connect(mapStateToProps, mapDispatchToProps)(CitationList) -- cgit v1.2.3-70-g09d2