diff --git a/src/Util.jsx b/src/Util.jsx index d3f5c31..e4b800d 100644 --- a/src/Util.jsx +++ b/src/Util.jsx @@ -1,33 +1,45 @@ import i18n from './i18n.jsx'; const colors = [ - '#6f0214', - '#b20616', - '#ff5d00', - '#ffb200', - '#6bca24', - '#019812', '#015411', + '#019812', + '#6bca24', + '#ffb200', + '#ff5d00', + '#b20616', + '#6f0214', ]; const gradeNames = [ - 'To reject', - 'Insufficient', - 'Passable', - 'Fair', - 'Good', - 'Very good', 'Excellent', + 'Very good', + 'Good', + 'Fair', + 'Passable', + 'Insufficient', + 'To reject', +]; + +const gradeValues = [ + 6, + 5, + 4, + 3, + 2, + 1, + 0 ]; export const grades = gradeNames.map((name, i) => ({ label: name, color: colors[i], + value: gradeValues[i] })); export const i18nGrades = () => { return gradeNames.map((name, i) => ({ label: i18n.t(name), color: colors[i], + value: gradeValues[i] })); }; diff --git a/src/components/layouts/Footer.jsx b/src/components/layouts/Footer.jsx index fa95260..82098fb 100644 --- a/src/components/layouts/Footer.jsx +++ b/src/components/layouts/Footer.jsx @@ -33,7 +33,6 @@ class Footer extends Component { style={linkStyle}> {t('Who are we?')} - -
diff --git a/src/components/views/Result.jsx b/src/components/views/Result.jsx index f615225..b47cdaf 100644 --- a/src/components/views/Result.jsx +++ b/src/components/views/Result.jsx @@ -166,7 +166,9 @@ class Result extends Component { render() { const {errorMessage, candidates, electionGrades} = this.state; const {t} = this.props; - const grades = i18nGrades(); + const i18nGradesObject = i18nGrades(); + const offsetGrade = i18nGradesObject.length-(this.state.numGrades); + if (errorMessage && errorMessage !== '') { return ; @@ -201,16 +203,17 @@ class Result extends Component {
    {candidates.map((candidate, i) => { + const gradeValue=candidate.grade+offsetGrade; return (
  1. {candidate.name} - {grades[candidate.grade].label} + {i18nGradesObject.slice(0).reverse()[gradeValue].label} {/* {(100 * candidate.score).toFixed(1)}% @@ -252,7 +255,7 @@ class Result extends Component { - {gradeIds.map((id, i) => { + {gradeIds.slice(0).reverse().map((id, i) => { const value = candidate.profile[id]; if (value > 0) { let percent = @@ -359,7 +362,7 @@ class Result extends Component { return ( - {gradeIds.map((id, i) => { + {gradeIds.slice(0).reverse().map((id, i) => { const value = candidate.profile[id]; const percent = ( (value / numVotes) * diff --git a/src/components/views/Vote.jsx b/src/components/views/Vote.jsx index 30e38e5..793ed5c 100644 --- a/src/components/views/Vote.jsx +++ b/src/components/views/Vote.jsx @@ -169,6 +169,7 @@ class Vote extends Component { render() { const {t} = this.props; const {redirectTo, candidates, electionGrades} = this.state; + const offsetGrade = i18nGrades().length-this.state.numGrades; if (redirectTo) { return ; @@ -220,7 +221,8 @@ class Vote extends Component {
    {this.state.electionGrades.map((grade, gradeId) => { - console.assert(gradeId < this.state.numGrades) + console.assert(gradeId < this.state.numGrades) + const gradeValue = grade.value-offsetGrade; return (
    {i + 1}