Skip to content

Commit

Permalink
Add subjectID prop
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Apr 15, 2021
1 parent d07a937 commit ebdf831
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/lib-classifier/dev/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class App extends React.Component {
.then(() => this.fetchProject())
}

onError (error, info) {
console.error(error)
}

initAuthorization () {
this.setState({ loading: true })
return oauth.init('7532a403edf16f31fb2a210b8a49f59553d45064e6c292679c3eac53631d73d1')
Expand Down Expand Up @@ -111,7 +115,9 @@ class App extends React.Component {
authClient={oauth}
onAddToCollection={(subjectId) => console.log(subjectId)}
onCompleteClassification={(classification, subject) => console.log('onComplete', classification, subject)}
onError={this.onError}
project={this.state.project}
subjectID={this.props.subjectID}
subjectSetID={this.props.subjectSetID}
workflowID={workflowID}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/lib-classifier/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ function getQueryParams() {
return {}
}

const { subjectSet, workflow } = getQueryParams()
ReactDOM.render(<App subjectSetID={subjectSet} workflowID={workflow} />, document.getElementById('root'))
const { subject, subjectSet, workflow } = getQueryParams()
ReactDOM.render(<App subjectID={subject} subjectSetID={subjectSet} workflowID={workflow} />, document.getElementById('root'))
20 changes: 14 additions & 6 deletions packages/lib-classifier/src/components/Classifier/Classifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Classifier({
onError = () => true,
onToggleFavourite = () => true,
project,
subjectID,
subjectSetID,
workflowID
}) {
Expand All @@ -79,25 +80,32 @@ export default function Classifier({
initialState: {}
})

const {
classifications,
projects,
userProjectPreferences,
workflows
} = classifierStore

useEffect(function onMount() {
classifierStore.setOnAddToCollection(onAddToCollection)
classifierStore.classifications.setOnComplete(onCompleteClassification)
classifications.setOnComplete(onCompleteClassification)
classifierStore.setOnToggleFavourite(onToggleFavourite)
}, [])

useEffect(function onProjectChange() {
classifierStore.projects.setResources([project])
classifierStore.projects.setActive(project.id)
projects.setResources([project])
projects.setActive(project.id)
}, [project.id])

useEffect(function onURLChange() {
if (workflowID) {
classifierStore.workflows.selectWorkflow(workflowID, subjectSetID)
workflows.selectWorkflow(workflowID, subjectSetID, subjectID)
}
}, [subjectSetID, workflowID])
}, [subjectID, subjectSetID, workflowID])

useEffect(function onAuthChange() {
classifierStore.userProjectPreferences.checkForUser()
userProjectPreferences.checkForUser()
}, [authClient])

try {
Expand Down

0 comments on commit ebdf831

Please sign in to comment.