Compare commits
No commits in common. "0f7ba3bedd1c11ed60d5b6f4c42e791a46e0e542" and "a7884d9a3b4883254a979124e14663b887b85821" have entirely different histories.
0f7ba3bedd
...
a7884d9a3b
3 changed files with 72 additions and 108 deletions
|
@ -2,7 +2,7 @@
|
|||
display:flex;
|
||||
flex:1;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#sortTxt{
|
||||
|
@ -12,19 +12,6 @@
|
|||
margin-right:1vw;
|
||||
}
|
||||
|
||||
#selectAndOrder{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#sortOrder{
|
||||
color: white;
|
||||
font-family:'Wellfleet',cursive;
|
||||
font-size: 1.2vw;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#selectBlock{
|
||||
background:#057B26;
|
||||
margin-left:1vw;
|
||||
|
|
|
@ -16,7 +16,6 @@ class Sort extends Component {
|
|||
<div id="sortTxt">
|
||||
Trier par
|
||||
</div>
|
||||
<div id="selectAndOrder">
|
||||
<div id="selectBlock">
|
||||
<div id="selectBox">
|
||||
<select id="sortSelect" onChange={this.props.handleChangeSortType}>
|
||||
|
@ -26,10 +25,6 @@ class Sort extends Component {
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="sortOrder" onClick={this.props.handleChangeSortOrder} hidden={this.props.orderIsVisible}>
|
||||
A-Z
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ export default class Stock extends React.Component {
|
|||
categorySorted:false,
|
||||
onSortedCategories:false,
|
||||
onSearch:false,
|
||||
sortOrder: 0,
|
||||
selectedArticles:[]
|
||||
}
|
||||
}
|
||||
|
@ -44,22 +43,13 @@ export default class Stock extends React.Component {
|
|||
this.getArticles()
|
||||
}
|
||||
|
||||
// Implémenter la fonction sortArticles :
|
||||
|
||||
sortArticles = (sortType) => {
|
||||
|
||||
let sorted;
|
||||
if (sortType === "name"){
|
||||
this.setState({orderIsVisible: false})
|
||||
if (this.state.sortOrder === 0) {
|
||||
//ordre alphabétique croissant
|
||||
sorted = [...this.state.articles].sort((a, b) => a.name.localeCompare(b.name))
|
||||
} else {
|
||||
//ordre alphabétique décroissant
|
||||
sorted = [...this.state.articles].sort((a, b) => b.name.localeCompare(a.name))
|
||||
}
|
||||
} else {
|
||||
this.setState({orderIsVisible: true})
|
||||
this.setState({sortOrder: 0})
|
||||
sorted = [...this.state.articles].sort((a, b) => b[sortType] - a[sortType]);
|
||||
}
|
||||
|
||||
|
@ -73,6 +63,9 @@ sortArticles = (sortType) => {
|
|||
this.setState({onSortedCategories:false})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
getArticles = () => {
|
||||
|
@ -134,7 +127,7 @@ sortArticles = (sortType) => {
|
|||
this.setState({onEditCategory:false})
|
||||
}
|
||||
|
||||
handleChangeSortType = (e) => {
|
||||
handleChangeSortType = e => {
|
||||
this.setState({sortType:e.target.value},()=>{
|
||||
if (this.state.sortType === "Ordre Alphabétique"){
|
||||
this.sortArticles("name")
|
||||
|
@ -147,18 +140,6 @@ sortArticles = (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({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");
|
||||
}
|
||||
|
||||
searchArticles = () => {
|
||||
this.setState({onSearch:true})
|
||||
let bodyFormData = new FormData()
|
||||
|
@ -200,6 +181,7 @@ sortArticles = (sortType) => {
|
|||
this.handleCloseCategories()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!sessionStorage.getItem('token')){
|
||||
|
@ -214,7 +196,7 @@ sortArticles = (sortType) => {
|
|||
: 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}/>
|
||||
</div>
|
||||
<div id="selectedBlock">
|
||||
<Selected/>
|
||||
|
|
Loading…
Reference in a new issue