@@ -5,17 +5,19 @@ import Results from './Results';
5
5
import MapSearch from './MapSearch' ;
6
6
import MyMap from './MyMap' ;
7
7
8
- import { connect } from 'react-redux' ;
9
- import { bindActionCreators } from 'redux' ;
10
- import * as mapActions from '../actions/map- actions' ;
8
+ import { connect } from 'react-redux' ;
9
+ import { bindActionCreators } from 'redux' ;
10
+ import * as actions from '../actions/actions' ;
11
11
12
12
class LocatorContainer extends Component {
13
13
render ( ) {
14
- const { markers} = this . props ;
14
+ const markers = this . props . storesFound . map ( ( store ) => {
15
+ return [ parseFloat ( store . Latitude ) , parseFloat ( store . Longitude ) ]
16
+ } )
15
17
16
18
return (
17
19
< div >
18
- < MapSearch searchStoresByPostcode = { this . props . actions . searchStoresByPostcode } />
20
+ < MapSearch onSearchPostcode = { this . props . actions . fetchStores } />
19
21
< button className = "btn btn-secondary btn-block mb-4 hidden-sm-up" > View Map</ button >
20
22
< Results />
21
23
< MyMap markers = { markers } />
@@ -25,19 +27,19 @@ class LocatorContainer extends Component {
25
27
}
26
28
27
29
LocatorContainer . propTypes = {
28
- markers : PropTypes . array . isRequired ,
30
+ storesFound : PropTypes . array . isRequired ,
29
31
actions : PropTypes . object . isRequired
30
32
} ;
31
33
32
34
const mapStateToProps = ( state , props ) => {
33
35
return {
34
- markers : state . map
36
+ storesFound : state . storesFound
35
37
} ;
36
38
}
37
39
38
40
const mapDispatchToProps = ( dispatch ) => {
39
41
return {
40
- actions : bindActionCreators ( mapActions , dispatch )
42
+ actions : bindActionCreators ( actions , dispatch )
41
43
}
42
44
}
43
45
0 commit comments