This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from MichaelKohler/feature/show-rejected-sent…
…ences feat: show rejected sentences (fixes #159)
- Loading branch information
Showing
9 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ dist | |
.env | ||
docker-compose.prod.yml | ||
.ignored_files | ||
.vscode | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react'; | ||
|
||
import WebDB from '../../web-db'; | ||
|
||
export default class Rejected extends React.Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
loading: true, | ||
rejectedSentences: {}, | ||
}; | ||
} | ||
|
||
async loadRejected() { | ||
if (!this.props.languages || this.props.languages.length < 1) { | ||
return; | ||
} | ||
|
||
const db = new WebDB(this.props.username, this.props.password); | ||
const rejectedSentences = await db.getAllRejectedByUsername(this.props.languages, this.props.username); | ||
this.setState({ | ||
rejectedSentences, | ||
loading: false, | ||
}); | ||
} | ||
|
||
componentDidMount() { | ||
this.loadRejected(); | ||
} | ||
|
||
render() { | ||
const { rejectedSentences, loading } = this.state; | ||
|
||
return ( | ||
<> | ||
<h1>Your rejected sentences</h1> | ||
|
||
{ loading && ( | ||
<p>Loading rejected sentences..</p> | ||
)} | ||
|
||
{ !loading && Object.keys(rejectedSentences).length === 0 && ( | ||
<p>No rejected sentences found!</p> | ||
)} | ||
|
||
{ Object.keys(rejectedSentences).map((language) => ( | ||
<section> | ||
<h2 key={language}>{language}</h2> | ||
|
||
<ul className="no-bullets"> | ||
{ rejectedSentences[language].map((sentence) => ( | ||
<li key={sentence}>{sentence}</li> | ||
))} | ||
</ul> | ||
</section> | ||
))} | ||
</> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { connect } from 'react-redux'; | ||
|
||
import Rejected from '../components/pages/rejected'; | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
username: state.username, | ||
password: state.password, | ||
languages: state.languages, | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(Rejected); |