source: phonelux-frontend/src/components/FiltersComponents/SpecificationsFilterComponent.js@ fd5b100

Last change on this file since fd5b100 was fd5b100, checked in by Marko <Marko@…>, 21 months ago

Edited filter components

  • Property mode set to 100644
File size: 5.2 KB
Line 
1import React, { Component } from 'react'
2import './SpecificationsFilterComponent.css'
3import FilterAltIcon from '@mui/icons-material/FilterAlt';
4import Tippy from '@tippyjs/react';
5import Popover from '@mui/material/Popover';
6import Typography from '@mui/material/Typography';
7import Button from '@mui/material/Button';
8import FilterSelectComponent from './FilterSelectComponent';
9import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
10import PickSpecificationComponent from '../PickSpecificationComponent/PickSpecificationComponent';
11import axios from 'axios';
12import UserContext from '../../context/UserContext';
13import SettingsIcon from '@mui/icons-material/Settings';
14export class SpecificationsFilterComponent extends Component {
15
16 constructor(props) {
17 super(props)
18
19 this.state = {
20 anchorEl: null,
21 openModal: false,
22 }
23 }
24
25 handleClick = (event) => {
26 this.setState({
27 anchorEl: event.currentTarget
28 })
29 };
30
31 handleClose = () => {
32 this.setState({
33 anchorEl: null
34 })
35 };
36
37 handleModalClose = () =>{
38 this.setState({
39 openModal: false
40 })
41 }
42
43 handleModalOpen = () =>{
44 this.setState({
45 openModal: true
46 })
47 }
48
49 render() {
50
51 const open = Boolean(this.state.anchorEl);
52 const id = open ? 'specifications-popover' : undefined;
53
54 return (
55 <div className='specifications-filter-main'>
56 <h4 aria-describedby={id} className='specifications-filter-header' onClick={this.handleClick}>
57 <FilterAltIcon className='specifications-filter-icon-header'/>Филтер за спецификации
58 <ArrowDropDownIcon style={{marginTop:'-2px'}}/>
59 </h4>
60 <Popover
61 className='specifications-filter-popover'
62 id={id}
63 open={open}
64 anchorEl={this.state.anchorEl}
65 onClose={this.handleClose}
66 anchorOrigin={{
67 vertical: 'center',
68 horizontal: 'right',
69 }}
70 >
71 <div className='popover-specification-container'>
72 <h2 className='popover-specification-container-header'>Филтер за спецификации</h2>
73 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("РАМ меморија") ?
74 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='ram'></FilterSelectComponent> : <></>
75 }
76 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("РОМ меморија") ?
77 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='rom'></FilterSelectComponent> : <></>
78 }
79 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Предна камера") ?
80 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='frontcamera'></FilterSelectComponent> : <></>
81 }
82 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Задна камера") ?
83 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='backcamera'></FilterSelectComponent> : <></>
84 }
85 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Чипсет") ?
86 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='chipset'></FilterSelectComponent> : <></>
87 }
88 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Процесор") ?
89 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='cpu'></FilterSelectComponent> : <></>
90 }
91 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Оперативен систем") ?
92 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='operatingsystem'></FilterSelectComponent> : <></>
93 }
94 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Боја") ?
95 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='color'></FilterSelectComponent> : <></>
96 }
97 { !localStorage.getItem('pickedSpecifications') || localStorage.getItem('pickedSpecifications').includes("Батерија") ?
98 <FilterSelectComponent changeHandler={this.props.changeHandler} width={400} type='battery'></FilterSelectComponent> : <></>
99 }
100 </div>
101 </Popover>
102 <h4 aria-describedby={id} className='pick-specifications-header' onClick={this.handleModalOpen}>
103 <SettingsIcon className='specifications-filter-icon-header'/>Спецификации за приказ
104 </h4>
105 { this.context.userId != '' && <PickSpecificationComponent
106 openModal={this.state.openModal}
107 handleClose={this.handleModalClose}/> }
108 </div>
109 )
110 }
111}
112
113SpecificationsFilterComponent.contextType = UserContext
114
115export default SpecificationsFilterComponent
116
Note: See TracBrowser for help on using the repository browser.