source: phonelux-frontend/src/components/HomepageComponent.js@ e5b84dc

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

Prototype version

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[dbd4834]1import React, { Component } from 'react'
2import GroupedFiltersComponent from './GroupedFiltersComponent/GroupedFiltersComponent'
3import HeaderComponent from './HeaderComponent/HeaderComponent'
4import PhoneCardGridComponent from './PhoneCardGridComponent/PhoneCardGridComponent'
5
[e5b84dc]6
[dbd4834]7export class HomepageComponent extends Component {
8
9constructor(props) {
10 super(props)
11
12 this.state = {
[e5b84dc]13 shops: '',
14 brands: '',
15 priceRange: '',
16 searchValue: '',
17 sortBy: 'mostPopular'
[dbd4834]18 }
19}
20
21changeFilters = (e) => {
22
23 if(e.hasOwnProperty('priceRange'))
24 {
25 this.setState({
26 priceRange: e.priceRange
27 })
28 }
29
30 if(e.hasOwnProperty('shops'))
31 {
32 this.setState({
33 shops: e.shops
34 })
35 }
36
37 if(e.hasOwnProperty('brands'))
38 {
39 this.setState({
40 brands: e.brands
41 })
42 }
43
44 if(e.hasOwnProperty('searchValue'))
45 {
46 this.setState({
47 searchValue: e.searchValue
48 })
[e5b84dc]49
[dbd4834]50 }
51
52 if(e.hasOwnProperty('sortBy'))
53 {
54 this.setState({
55 sortBy: e.sortBy
56 })
57 }
58}
59
[e5b84dc]60
[dbd4834]61 render() {
62 return (
63 <>
64 <HeaderComponent/>
65 <GroupedFiltersComponent passFilters={this.changeFilters}/>
[e5b84dc]66 <PhoneCardGridComponent {...this.state}/>
[dbd4834]67 </>
68 )
69 }
70}
71
72export default HomepageComponent
Note: See TracBrowser for help on using the repository browser.