Last change
on this file since 5201690 was 7e88e46, checked in by Marko <Marko@…>, 22 months ago |
Added more components
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[dbd4834] | 1 | import React, { Component } from 'react'
|
---|
[7e88e46] | 2 | import UserContext from '../context/UserContext'
|
---|
[dbd4834] | 3 | import GroupedFiltersComponent from './GroupedFiltersComponent/GroupedFiltersComponent'
|
---|
| 4 | import HeaderComponent from './HeaderComponent/HeaderComponent'
|
---|
| 5 | import PhoneCardGridComponent from './PhoneCardGridComponent/PhoneCardGridComponent'
|
---|
| 6 |
|
---|
[e5b84dc] | 7 |
|
---|
[dbd4834] | 8 | export class HomepageComponent extends Component {
|
---|
| 9 |
|
---|
| 10 | constructor(props) {
|
---|
| 11 | super(props)
|
---|
| 12 |
|
---|
| 13 | this.state = {
|
---|
[e5b84dc] | 14 | shops: '',
|
---|
| 15 | brands: '',
|
---|
| 16 | priceRange: '',
|
---|
| 17 | searchValue: '',
|
---|
| 18 | sortBy: 'mostPopular'
|
---|
[dbd4834] | 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 | })
|
---|
[e5b84dc] | 50 |
|
---|
[dbd4834] | 51 | }
|
---|
[7e88e46] | 52 |
|
---|
[dbd4834] | 53 | if(e.hasOwnProperty('sortBy'))
|
---|
| 54 | {
|
---|
| 55 | this.setState({
|
---|
| 56 | sortBy: e.sortBy
|
---|
| 57 | })
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[e5b84dc] | 61 |
|
---|
[dbd4834] | 62 | render() {
|
---|
[7e88e46] | 63 | console.log(this.context)
|
---|
| 64 | console.log(localStorage.getItem('token'))
|
---|
[dbd4834] | 65 | return (
|
---|
| 66 | <>
|
---|
| 67 | <HeaderComponent/>
|
---|
| 68 | <GroupedFiltersComponent passFilters={this.changeFilters}/>
|
---|
[e5b84dc] | 69 | <PhoneCardGridComponent {...this.state}/>
|
---|
[dbd4834] | 70 | </>
|
---|
| 71 | )
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[7e88e46] | 75 | HomepageComponent.contextType = UserContext
|
---|
| 76 |
|
---|
| 77 |
|
---|
[dbd4834] | 78 | export default HomepageComponent
|
---|
Note:
See
TracBrowser
for help on using the repository browser.