diff --git a/src/js/Components/Sort.js b/src/js/Components/Sort.js index 6a05b59..93f7dad 100644 --- a/src/js/Components/Sort.js +++ b/src/js/Components/Sort.js @@ -23,10 +23,11 @@ class Sort extends Component { + -
+
{this.props.lowToHigh ? "A-Z" : "Z-A"}
diff --git a/src/js/Views/Stock.js b/src/js/Views/Stock.js index 67789da..9b3bec1 100644 --- a/src/js/Views/Stock.js +++ b/src/js/Views/Stock.js @@ -17,7 +17,6 @@ import EditCategory from '../Components/EditCategory'; import Sort from '../Components/Sort'; import { Link } from 'react-router-dom'; import Selected from '../Components/Selected'; -import BarcodeReader from 'react-barcode-reader' export default class Stock extends React.Component { @@ -67,8 +66,9 @@ export default class Stock extends React.Component { sortArticles = (sortType) => { let sorted; + //TRI PAR ORDRE ALPHABETIQUE if (sortType === "name"){ - this.setState({orderIsVisible: false}) + this.setState({orderIsHidden: false}) if (this.state.lowToHigh) { //ordre alphabétique croissant sorted = [...this.state.articles].sort((a, b) => a.name.localeCompare(b.name)) @@ -77,21 +77,27 @@ export default class Stock extends React.Component { sorted = [...this.state.articles].sort((a, b) => b.name.localeCompare(a.name)) } } else { - this.setState({orderIsVisible: true}) + this.setState({orderIsHidden: true}) this.setState({lowToHigh: false}) sorted = [...this.state.articles].sort((a, b) => b[sortType] - a[sortType]); } + //TRI PAR CATEGORIE if (sortType === 'category_id'){ - this.setState({articles:sorted},() => { - this.setState({onSortedCategories:true}) - }) + this.setState({articles:sorted},() => { + this.setState({onSortedCategories:true}) + }) }else{ this.setState({articles:sorted},() => { console.log(this.state.articles) this.setState({onSortedCategories:false}) }) } + + //TRI PAR PRIX + if (sortType === 'price') { + + } } getArticles = () => { @@ -161,6 +167,8 @@ export default class Stock extends React.Component { this.sortArticles("category_id") } else if(this.state.sortType === "Quantité"){ this.sortArticles("quantity") + } else if(this.state.sortType === "Prix"){ + this.sortArticles("price"); } }) @@ -216,19 +224,12 @@ export default class Stock extends React.Component { } } - handleScan = (data) => { - this.setState({code:data},()=>{ - console.log(this.state.code) - }) - } - render() { if (!sessionStorage.getItem('token')){ return (- Scanne tes articles pour remplir le ticket de caisse ! -
-+ Scanne tes articles pour remplir le ticket de caisse ! +
+