Rev | Line | |
---|
[dbd4834] | 1 | import React, { Component } from 'react'
|
---|
[d66b8eb] | 2 | import { Link } from 'react-router-dom'
|
---|
[dbd4834] | 3 | import './SortByComponent.css'
|
---|
[d66b8eb] | 4 | import SpecificationsFilterComponent from './SpecificationsFilterComponent'
|
---|
[48f3030] | 5 | import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
---|
| 6 | import PickSpecificationComponent from '../PickSpecificationComponent/PickSpecificationComponent';
|
---|
[dbd4834] | 7 |
|
---|
| 8 | export class SortByComponent extends Component {
|
---|
| 9 |
|
---|
| 10 | constructor(props) {
|
---|
| 11 | super(props)
|
---|
| 12 |
|
---|
| 13 | this.state = {
|
---|
[48f3030] | 14 | sortBy: localStorage.getItem('sortBy') ? localStorage.getItem('sortBy') : 'mostPopular',
|
---|
| 15 | openModal: false
|
---|
[dbd4834] | 16 | }
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | handleChange = (e) => {
|
---|
| 20 | this.props.changeHandler({sortBy: e.target.value})
|
---|
[d66b8eb] | 21 | localStorage.setItem('sortBy',e.target.value)
|
---|
[dbd4834] | 22 | }
|
---|
| 23 |
|
---|
| 24 | render() {
|
---|
| 25 | return (
|
---|
| 26 | <div className="sortby-component-wrapper">
|
---|
[d66b8eb] | 27 | {localStorage.getItem('token') ? <SpecificationsFilterComponent changeHandler={this.props.changeHandler}/> : <></>}
|
---|
| 28 | <select defaultValue={this.state.sortBy} onChange={this.handleChange} className='sortby-component-select'>
|
---|
[dbd4834] | 29 | <option value="mostPopular">Најпопуларно</option>
|
---|
| 30 | <option value="ascending">Цена: Ниска {'>'} Висока</option>
|
---|
| 31 | <option value="descending">Цена: Висока {'>'} Ниска</option>
|
---|
| 32 | </select>
|
---|
| 33 | </div>
|
---|
| 34 | )
|
---|
| 35 | }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | export default SortByComponent
|
---|
Note:
See
TracBrowser
for help on using the repository browser.