Changeset d66b8eb for phonelux-frontend/src/components/FiltersComponents
- Timestamp:
- 09/21/22 18:47:39 (2 years ago)
- Branches:
- master
- Children:
- 34950c6
- Parents:
- 5201690
- Location:
- phonelux-frontend/src/components/FiltersComponents
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
phonelux-frontend/src/components/FiltersComponents/FilterPriceComponent.js
r5201690 rd66b8eb 11 11 12 12 this.state = { 13 value: [1000,150000], 13 value: localStorage.getItem('priceRange') ? [parseInt(localStorage.getItem('priceRange').split('-')[0]), 14 parseInt(localStorage.getItem('priceRange').split('-')[1])] : [1000,150000], 14 15 minValue: 0, 15 16 maxValue: 0 … … 39 40 handleChange = () => { 40 41 this.props.changeHandler({priceRange: this.state.value.join('-')}) 42 localStorage.setItem('priceRange',this.state.value.join('-')) 41 43 } 42 44 -
phonelux-frontend/src/components/FiltersComponents/FilterSelectComponent.css
r5201690 rd66b8eb 7 7 8 8 } 9 10 .list-item-text-filters span{ 11 overflow-x: scroll; 12 } -
phonelux-frontend/src/components/FiltersComponents/FilterSelectComponent.js
r5201690 rd66b8eb 15 15 constructor(props) { 16 16 super(props) 17 17 const {type} = this.props 18 console.log(type) 18 19 this.state = { 19 pickedItems: [],20 pickedItems: localStorage.getItem(type) ? localStorage.getItem(type).split(',') : [], 20 21 items: [], 21 22 type: '', … … 37 38 } 38 39 39 40 40 let endpoint 41 if(this.props.type == 'brands') 42 { 43 endpoint = '/brands' 41 switch (this.props.type) { 42 43 case 'brands': 44 endpoint = '/brands' 44 45 this.setState({ 45 46 type: 'Брендови' 46 47 }) 47 }48 else{49 endpoint = '/shops'48 break; 49 case 'shops': 50 endpoint = '/shops' 50 51 this.setState({ 51 52 type: 'Продавници' 52 53 }) 54 break; 55 56 case 'ram': 57 endpoint = '/specifications/ram' 58 this.setState({ 59 type: 'РАМ меморија' 60 }) 61 break; 62 63 case 'rom': 64 endpoint = '/specifications/rom' 65 this.setState({ 66 type: 'РОМ меморија' 67 }) 68 break; 69 70 case 'frontcamera': 71 endpoint = '/specifications/frontcamera' 72 this.setState({ 73 type: 'Предна камера' 74 }) 75 break; 76 77 case 'backcamera': 78 endpoint = '/specifications/backcamera' 79 this.setState({ 80 type: 'Задна камера' 81 }) 82 break; 83 84 case 'chipset': 85 endpoint = '/specifications/chipset' 86 this.setState({ 87 type: 'Чипсет' 88 }) 89 break; 90 91 case 'cpu': 92 endpoint = '/specifications/cpu' 93 this.setState({ 94 type: 'Процесор' 95 }) 96 break; 97 98 99 case 'operatingsystem': 100 endpoint = '/specifications/operatingsystem' 101 this.setState({ 102 type: 'Оперативен систем' 103 }) 104 break; 105 106 107 case 'color': 108 endpoint = '/specifications/color' 109 this.setState({ 110 type: 'Боја' 111 }) 112 break; 113 114 case 'battery': 115 endpoint = '/specifications/battery' 116 this.setState({ 117 type: 'Батерија' 118 }) 119 break; 120 121 default: 122 break; 53 123 } 54 124 … … 63 133 pickedItems: typeof value === 'string' ? value.split(',') : value 64 134 }, ()=>{ 65 if(this.props.type == 'brands') 66 { 67 this.props.changeHandler({brands: this.state.pickedItems.join(',')}) 135 136 switch (this.props.type) { 137 case 'brands': 138 this.props.changeHandler({brands: this.state.pickedItems.join(',')}) 139 localStorage.setItem('brands', this.state.pickedItems.join(',')) 140 break; 141 142 case 'shops': 143 this.props.changeHandler({shops: this.state.pickedItems.join(',')}) 144 localStorage.setItem('shops', this.state.pickedItems.join(',')) 145 break; 146 147 case 'ram': 148 this.props.changeHandler({ram: this.state.pickedItems.join(',')}) 149 localStorage.setItem('ram', this.state.pickedItems.join(',')) 150 break; 151 case 'rom': 152 this.props.changeHandler({rom: this.state.pickedItems.join(',')}) 153 localStorage.setItem('rom', this.state.pickedItems.join(',')) 154 break; 155 case 'frontcamera': 156 this.props.changeHandler({frontcamera: this.state.pickedItems.join(',')}) 157 localStorage.setItem('frontcamera', this.state.pickedItems.join(',')) 158 break; 159 160 case 'backcamera': 161 this.props.changeHandler({backcamera: this.state.pickedItems.join(',')}) 162 localStorage.setItem('backcamera', this.state.pickedItems.join(',')) 163 break; 164 165 case 'chipset': 166 this.props.changeHandler({chipset: this.state.pickedItems.join(',')}) 167 localStorage.setItem('chipset', this.state.pickedItems.join(',')) 168 break; 169 170 case 'cpu': 171 this.props.changeHandler({cpu: this.state.pickedItems.join(',')}) 172 localStorage.setItem('cpu', this.state.pickedItems.join(',')) 173 break; 174 175 case 'operatingsystem': 176 this.props.changeHandler({operatingsystem: this.state.pickedItems.join(',')}) 177 localStorage.setItem('operatingsystem', this.state.pickedItems.join(',')) 178 break; 179 180 case 'color': 181 this.props.changeHandler({color: this.state.pickedItems.join(',')}) 182 localStorage.setItem('color', this.state.pickedItems.join(',')) 183 break; 184 185 case 'battery': 186 this.props.changeHandler({battery: this.state.pickedItems.join(',')}) 187 localStorage.setItem('battery', this.state.pickedItems.join(',')) 188 break; 189 190 default: 191 break; 68 192 } 193 // if(this.props.type == 'brands') 194 // { 195 // this.props.changeHandler({brands: this.state.pickedItems.join(',')}) 196 // } 69 197 70 if(this.props.type == 'shops')71 {72 this.props.changeHandler({shops: this.state.pickedItems.join(',')})73 }198 // if(this.props.type == 'shops') 199 // { 200 // this.props.changeHandler({shops: this.state.pickedItems.join(',')}) 201 // } 74 202 75 203 }) 204 205 76 206 }; 77 207 // sx={{ m: 1, width: 250 }} kaj formcontrol 78 208 79 209 render() { 80 210 return ( 81 211 <div> 82 <FormControl className="form-select-component" sx={{ m: 1, width: 200}}>212 <FormControl className="form-select-component" sx={{ m: 1, width: this.props.width}}> 83 213 <InputLabel className="input-select-label">{this.state.type}</InputLabel> 84 214 <Select … … 94 224 > 95 225 {this.state.items.map((item) => ( 96 <MenuItem key={item} value={item} >226 <MenuItem key={item} value={item} > 97 227 <Checkbox checked={this.state.pickedItems.indexOf(item) > -1} /> 98 <ListItemText primary={item} />228 <ListItemText className='list-item-text-filters' primary={item} /> 99 229 </MenuItem> 100 230 ))} -
phonelux-frontend/src/components/FiltersComponents/SearchFieldComponent.js
r5201690 rd66b8eb 63 63 64 64 this.state = { 65 65 66 66 } 67 67 } -
phonelux-frontend/src/components/FiltersComponents/SortByComponent.css
r5201690 rd66b8eb 1 1 .sortby-component-wrapper{ 2 2 display: flex; 3 justify-content: end;3 justify-content: space-between; 4 4 padding: 20px; 5 5 background-color: #DEE4E1 … … 11 11 background-color: #e6f8ef; 12 12 margin-right: 15px; 13 height: 50%; 14 margin-left: auto; 13 15 } 16 17 18 .popover-specification-container{ 19 height: 500px; 20 overflow-y: scroll; 21 } -
phonelux-frontend/src/components/FiltersComponents/SortByComponent.js
r5201690 rd66b8eb 1 1 import React, { Component } from 'react' 2 import { Link } from 'react-router-dom' 2 3 import './SortByComponent.css' 4 import SpecificationsFilterComponent from './SpecificationsFilterComponent' 3 5 4 6 export class SortByComponent extends Component { … … 8 10 9 11 this.state = { 10 sortBy: 'mostPopular'12 sortBy: localStorage.getItem('sortBy') ? localStorage.getItem('sortBy') : 'mostPopular' 11 13 } 12 14 } … … 14 16 handleChange = (e) => { 15 17 this.props.changeHandler({sortBy: e.target.value}) 18 localStorage.setItem('sortBy',e.target.value) 16 19 } 17 20 … … 19 22 return ( 20 23 <div className="sortby-component-wrapper"> 21 <select defaultValue={'mostPopular'} onChange={this.handleChange} className='sortby-component-select'> 24 {localStorage.getItem('token') ? <SpecificationsFilterComponent changeHandler={this.props.changeHandler}/> : <></>} 25 <select defaultValue={this.state.sortBy} onChange={this.handleChange} className='sortby-component-select'> 22 26 <option value="mostPopular">Најпопуларно</option> 23 27 <option value="ascending">Цена: Ниска {'>'} Висока</option>
Note:
See TracChangeset
for help on using the changeset viewer.