Merge branch 'master' of https://git.etud.insa-toulouse.fr/bamarty/Site-Proximo
This commit is contained in:
commit
6d41983135
2 changed files with 11 additions and 16 deletions
|
@ -26,9 +26,9 @@ class Sort extends Component {
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="sortOrder" onClick={this.props.handleChangeSortOrder} hidden={this.props.orderIsVisible}>
|
||||
A-Z
|
||||
</div>
|
||||
<p id="sortOrder" onClick={this.props.handleChangeSortOrder} hidden={this.props.orderIsVisible}>
|
||||
{this.props.lowToHigh ? "A-Z" : "Z-A"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -36,7 +36,7 @@ export default class Stock extends React.Component {
|
|||
categorySorted:false,
|
||||
onSortedCategories:false,
|
||||
onSearch:false,
|
||||
sortOrder: 0,
|
||||
lowToHigh: true,
|
||||
selectedArticles:[],
|
||||
counter:0,
|
||||
code:''
|
||||
|
@ -69,7 +69,7 @@ export default class Stock extends React.Component {
|
|||
let sorted;
|
||||
if (sortType === "name"){
|
||||
this.setState({orderIsVisible: false})
|
||||
if (this.state.sortOrder === 0) {
|
||||
if (this.state.lowToHigh) {
|
||||
//ordre alphabétique croissant
|
||||
sorted = [...this.state.articles].sort((a, b) => a.name.localeCompare(b.name))
|
||||
} else {
|
||||
|
@ -78,7 +78,7 @@ export default class Stock extends React.Component {
|
|||
}
|
||||
} else {
|
||||
this.setState({orderIsVisible: true})
|
||||
this.setState({sortOrder: 0})
|
||||
this.setState({lowToHigh: false})
|
||||
sorted = [...this.state.articles].sort((a, b) => b[sortType] - a[sortType]);
|
||||
}
|
||||
|
||||
|
@ -167,15 +167,10 @@ export default class Stock extends React.Component {
|
|||
}
|
||||
|
||||
//Gère le choix de tri par ordre croissant ou décroissant quand c'est possible avec le tri actuel
|
||||
handleChangeSortOrder = (e) => {
|
||||
this.setState({sortOrder: (this.state.sortOrder + 1) % 2});
|
||||
console.log(this.state.sortOrder)
|
||||
if (this.state.sortOrder === 1) {
|
||||
e.target.innerHTML = "Z-A"
|
||||
} else {
|
||||
e.target.innerHTML = "A-Z"
|
||||
}
|
||||
this.sortArticles("name");
|
||||
handleChangeSortOrder = e => {
|
||||
this.setState({lowToHigh: (this.state.lowToHigh + 1) % 2},() => {
|
||||
this.sortArticles("name");
|
||||
});
|
||||
}
|
||||
|
||||
searchArticles = () => {
|
||||
|
@ -241,7 +236,7 @@ export default class Stock extends React.Component {
|
|||
: null}
|
||||
<SearchBar handleSubmit={this.handleSubmit} handleSearchChange={this.handleSearchChange}/>
|
||||
<div id="sortBlock">
|
||||
<Sort handleChangeSortType={this.handleChangeSortType} handleChangeSortOrder={this.handleChangeSortOrder} orderIsVisible={this.state.orderIsVisible}/>
|
||||
<Sort handleChangeSortType={this.handleChangeSortType} handleChangeSortOrder={this.handleChangeSortOrder} orderIsVisible={this.state.orderIsVisible} lowToHigh={this.state.lowToHigh}/>
|
||||
</div>
|
||||
<div id="selectedBlock">
|
||||
<Selected counter={this.state.counter}/>
|
||||
|
|
Loading…
Reference in a new issue