Router in a good shape

This commit is contained in:
Edin Dazdarevic
2017-04-09 19:34:08 +02:00
parent 562bbc638f
commit 1fdcc24827
7 changed files with 160 additions and 40 deletions

View File

@@ -22,8 +22,22 @@ export default class Listings extends React.Component {
}
onListingClick(id) {
loadListing(id).then(l => l.text()).then(l => {
console.log('listing loaded', l);
console.log('lising clicked');
this.props.dispatch({type: 'UPDATE_ROUTE', action: {
toDispatch: {
type: 'VIEW_LISTING_DETAILS', action: {
id,
listing: JSON.parse(l)
}
},
params: {
listingId: id
}
}});
this.props.dispatch({type: 'VIEW_LISTING_DETAILS', action: {
id,
listing: JSON.parse(l)
@@ -108,6 +122,12 @@ export default class Listings extends React.Component {
}
onSortChange (e) {
this.props.dispatch({type: 'UPDATE_ROUTE', action: {
params: {
sort: e.target.value
}
}});
this.props.dispatch({type: 'SORT_CHANGE', action: {
sort: e.target.value
}});