diff --git a/src/js/Components/Sort.js b/src/js/Components/Sort.js
index 38c2d2d..54d20be 100644
--- a/src/js/Components/Sort.js
+++ b/src/js/Components/Sort.js
@@ -20,10 +20,10 @@ class Sort extends Component {
diff --git a/src/js/Views/Stock.js b/src/js/Views/Stock.js
index 699d758..195102d 100644
--- a/src/js/Views/Stock.js
+++ b/src/js/Views/Stock.js
@@ -68,7 +68,7 @@ export default class Stock extends React.Component {
let sorted;
//TRI PAR ORDRE ALPHABETIQUE OU PRIX
if (sortType === "name"){
- this.setState({orderIsHidden: false})
+ this.setState({orderIsHidden: false}) //choix d'ordre possible
if (this.state.lowToHigh) {
//ordre alphabétique croissant
sorted = [...this.state.articles].sort((a, b) => a.name.localeCompare(b.name))
@@ -78,7 +78,7 @@ export default class Stock extends React.Component {
}
} else if (sortType === "price") {
console.log('tri pix')
- this.setState({orderIsHidden: false})
+ this.setState({orderIsHidden: false}) //choix d'ordre possible
if (this.state.lowToHigh) {
//ordre croissant
sorted = [...this.state.articles].sort((a, b) => a.price - b.price)
@@ -167,26 +167,34 @@ export default class Stock extends React.Component {
this.setState({onEditCategory:false})
}
+ // handleChangeSortType = (e) => {
+ // console.log(e.target.value)
+ // this.setState({sortType:e.target.value},()=>{
+ // if (this.state.sortType === "Ordre Alphabétique"){
+ // this.sortArticles("name")
+ // } else if(this.state.sortType === "Catégorie"){
+ // this.sortArticles("category_id")
+ // } else if(this.state.sortType === "Quantité"){
+ // this.sortArticles("quantity")
+ // } else if(this.state.sortType === "Prix"){
+ // this.sortArticles("price");
+ // }
+
+ // })
+ // }
+
handleChangeSortType = (e) => {
console.log(e.target.value)
- this.setState({sortType:e.target.value},()=>{
- if (this.state.sortType === "Ordre Alphabétique"){
- this.sortArticles("name")
- } else if(this.state.sortType === "Catégorie"){
- this.sortArticles("category_id")
- } else if(this.state.sortType === "Quantité"){
- this.sortArticles("quantity")
- } else if(this.state.sortType === "Prix"){
- this.sortArticles("price");
- }
-
+ this.setState({sortType: e.target.value}, () => {
+ this.sortArticles(this.state.sortType)
})
}
//Gère le choix de tri par ordre croissant ou décroissant quand c'est possible avec le tri actuel
handleChangeSortOrder = e => {
this.setState({lowToHigh: (this.state.lowToHigh + 1) % 2},() => {
- this.sortArticles("name");
+ console.log(this.state.sortType)
+ this.sortArticles(this.state.sortType);
});
}