Last change
on this file since 7e88e46 was 7e88e46, checked in by Marko <Marko@…>, 22 months ago |
Added more components
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | import React, { Component } from 'react'
|
---|
2 | import UserContext from '../context/UserContext'
|
---|
3 | import GroupedFiltersComponent from './GroupedFiltersComponent/GroupedFiltersComponent'
|
---|
4 | import HeaderComponent from './HeaderComponent/HeaderComponent'
|
---|
5 | import PhoneCardGridComponent from './PhoneCardGridComponent/PhoneCardGridComponent'
|
---|
6 |
|
---|
7 |
|
---|
8 | export class HomepageComponent extends Component {
|
---|
9 |
|
---|
10 | constructor(props) {
|
---|
11 | super(props)
|
---|
12 |
|
---|
13 | this.state = {
|
---|
14 | shops: '',
|
---|
15 | brands: '',
|
---|
16 | priceRange: '',
|
---|
17 | searchValue: '',
|
---|
18 | sortBy: 'mostPopular'
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | changeFilters = (e) => {
|
---|
23 |
|
---|
24 | if(e.hasOwnProperty('priceRange'))
|
---|
25 | {
|
---|
26 | this.setState({
|
---|
27 | priceRange: e.priceRange
|
---|
28 | })
|
---|
29 | }
|
---|
30 |
|
---|
31 | if(e.hasOwnProperty('shops'))
|
---|
32 | {
|
---|
33 | this.setState({
|
---|
34 | shops: e.shops
|
---|
35 | })
|
---|
36 | }
|
---|
37 |
|
---|
38 | if(e.hasOwnProperty('brands'))
|
---|
39 | {
|
---|
40 | this.setState({
|
---|
41 | brands: e.brands
|
---|
42 | })
|
---|
43 | }
|
---|
44 |
|
---|
45 | if(e.hasOwnProperty('searchValue'))
|
---|
46 | {
|
---|
47 | this.setState({
|
---|
48 | searchValue: e.searchValue
|
---|
49 | })
|
---|
50 |
|
---|
51 | }
|
---|
52 |
|
---|
53 | if(e.hasOwnProperty('sortBy'))
|
---|
54 | {
|
---|
55 | this.setState({
|
---|
56 | sortBy: e.sortBy
|
---|
57 | })
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | render() {
|
---|
63 | console.log(this.context)
|
---|
64 | console.log(localStorage.getItem('token'))
|
---|
65 | return (
|
---|
66 | <>
|
---|
67 | <HeaderComponent/>
|
---|
68 | <GroupedFiltersComponent passFilters={this.changeFilters}/>
|
---|
69 | <PhoneCardGridComponent {...this.state}/>
|
---|
70 | </>
|
---|
71 | )
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | HomepageComponent.contextType = UserContext
|
---|
76 |
|
---|
77 |
|
---|
78 | export default HomepageComponent
|
---|
Note:
See
TracBrowser
for help on using the repository browser.