From e5c69daa3c2428a067c61baca3d20c96398f9354 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 20 Mar 2019 01:48:55 +0100 Subject: s2 geocode server --- scraper/client/paper/paper.verify.js | 61 +++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'scraper/client/paper/paper.verify.js') diff --git a/scraper/client/paper/paper.verify.js b/scraper/client/paper/paper.verify.js index cfce8f28..570899d5 100644 --- a/scraper/client/paper/paper.verify.js +++ b/scraper/client/paper/paper.verify.js @@ -10,7 +10,8 @@ import { Loader, Autocomplete } from '../common' const initialState = { citation: null, - verify: '', + uses_paper: false, + doesnt_use_paper: false, verified_by: '', notes: '', pdf_index: 0, @@ -24,7 +25,7 @@ class PaperVerify extends Component { const { sha256 } = this.props.match.params this.props.actions.getInstitutions() this.props.actions.getVerification(sha256) - const citationState = this.getVerificationState(sha256) + const citationState = this.getCitationState(sha256) console.log('DID MOUNT') this.setState(citationState) } @@ -55,12 +56,14 @@ class PaperVerify extends Component { }) } else { // console.log(paper) - console.log('GOT CUSTOM ADDRESS') + console.log('GOT CUSTOM CITATION STATE') const citationState = this.getCitationState(sha256) this.setState({ ...citationState, - verified: paper.verified, + uses_paper: paper.uses_paper, + doesnt_use_paper: paper.doesnt_use_paper, verified_by: paper.verified_by, + notes: paper.notes, }) } } else if (oldProps.api.unknownCitations !== this.props.api.unknownCitations) { @@ -77,12 +80,6 @@ class PaperVerify extends Component { } // console.log(sha256, citation) let state = { citation } - let addresses = citation ? citation.addresses : [] - if (addresses) { - addresses.forEach((address, i) => { - state['institution_' + (i + 1)] = address.address - }) - } return state } @@ -91,7 +88,8 @@ class PaperVerify extends Component { this.props.actions.postVerification({ paper_id: this.state.citation.id, title: this.state.citation.title, - verified: this.state.verified, + uses_paper: this.state.uses_paper, + doesnt_use_paper: this.state.doesnt_use_paper, verified_by: this.state.verified_by, notes: this.state.notes, }) @@ -100,31 +98,31 @@ class PaperVerify extends Component { next() { const { key } = this.props.api.paperInfo.dataset - const { unknownCitations } = this.props.api - let citationIndex = (unknownCitations.citations || []) + const { paperInfo } = this.props.api + let citationIndex = (paperInfo.citations || []) .findIndex(f => f.id === this.state.citation.id) if (citationIndex === -1) { history.push('/paper/' + key + '/info/') } else { citationIndex += 1 - if (citationIndex >= unknownCitations.length) { + if (citationIndex >= paperInfo.citations.length) { history.push('/paper/' + key + '/info/') } else { - let nextId = unknownCitations.citations[citationIndex].id - history.push('/paper/' + key + '/address/' + nextId) + let nextId = paperInfo.citations[citationIndex].id + history.push('/paper/' + key + '/verify/' + nextId) } } } render() { - let { paperInfo, unknownCitations } = this.props.api - if (paperInfo.loading || unknownCitations.loading) return - console.log(this.state) + let { paperInfo } = this.props.api + if (paperInfo.loading) return + // console.log(this.state) const { citation } = this.state if (!citation) { return
Citation not found in this paper
} - console.log(citation) + // console.log(citation) return (

{citation.title}

@@ -146,27 +144,38 @@ class PaperVerify extends Component {
+ this.setState({ - verified: e.target.value, - })} + checked={!!this.state.uses_paper} + onChange={e => this.setState({ uses_paper: e.target.checked })} />
+ + this.setState({ doesnt_use_paper: e.target.checked })} + /> +
+ +
+ this.setState({ notes: e.target.value })} + onChange={e => this.setState({ verified_by: e.target.value })} />
+ {'Next >'}
-