Skip to content

Commit

Permalink
Fixing filter 'select affiliation'
Browse files Browse the repository at this point in the history
Creating an array of affiliation categories and then add to
this array a default option 'all'. Then create a map of JSX from each item
including 'all' item.

Fixes #92
  • Loading branch information
Kha committed Apr 8, 2021
1 parent 5252486 commit 6a943d2
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import React, { Component } from 'react'
import django from 'django'

export default class Filter extends React.Component {
export default class Filter extends Component {
selectCategory (e) {
e.preventDefault()
const category = e.target.getAttribute('data-value')
Expand All @@ -17,7 +17,8 @@ export default class Filter extends React.Component {
}

render () {
const allTag = django.gettext('all')
const categories = [...this.props.categories]
categories.unshift(django.gettext('all'))
const onlyShowMarkedText = django.gettext('only show marked questions')
const displayNotHiddenText = django.gettext('display only questions which are not hidden')
const orderLikesText = django.gettext('order by likes')
Expand All @@ -32,8 +33,7 @@ export default class Filter extends React.Component {
<i className="fa fa-caret-down" aria-hidden="true" />
</button>
<div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
<button className="dropdown-item" data-value={-1} onClick={this.selectCategory.bind(this)} href="#">{allTag}</button>
{this.props.categories.map((category, index) => {
{categories.map((category, index) => {
return <button className="dropdown-item" key={index} data-value={category} onClick={this.selectCategory.bind(this)} href="#">{category}</button>
})}
</div>
Expand Down

0 comments on commit 6a943d2

Please sign in to comment.