source: phonelux-frontend/src/components/FiltersComponents/FilterPriceComponent.js@ dbd4834

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

Homepage, login and register components added

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import * as React from 'react';
2import Box from '@mui/material/Box';
3import Slider from '@mui/material/Slider';
4import "./FilterPriceComponent.css"
5import axios from 'axios';
6
7export class FilterPriceComponent extends React.Component {
8
9 constructor(props) {
10 super(props)
11
12 this.state = {
13 value: [1000,150000],
14 minValue: 0,
15 maxValue: 0
16 }
17 }
18
19 componentDidMount(){
20
21
22 axios.get('/lowestPrice')
23 .then(response => this.setState({minValue: response.data}))
24 .catch(error => console.log(error))
25
26 axios.get('/highestPrice')
27 .then(response => this.setState({
28 maxValue: response.data,
29 }))
30 .catch(error => console.log(error))
31
32 }
33
34 changeValue = (event, newValue) => {
35 this.setState({
36 value: newValue
37 });
38 };
39
40 handleChange = () => {
41 this.props.changeHandler({priceRange: this.state.value.join('-')})
42 }
43
44
45 render() {
46 return (
47 <div className="sliderPriceContainer">
48 <label className="sliderPriceLabel">Цена:</label>
49 <Box className="sliderBox" sx={{ width: 280 }}>
50 <Slider
51 id="priceSlider"
52 getAriaLabel={() => 'Price range'}
53 value={this.state.value}
54 onChange={this.changeValue}
55 onChangeCommitted={this.handleChange}
56 valueLabelDisplay="auto"
57 min={this.state.minValue}
58 max={this.state.maxValue}
59 />
60 </Box>
61 </div>
62 );
63 }
64}
65
66export default FilterPriceComponent
67
Note: See TracBrowser for help on using the repository browser.