Load listing details from the server

This commit is contained in:
Edin Dazdarevic
2017-04-08 00:06:06 +02:00
parent a1e4a35d17
commit ffdf1d36b3
6 changed files with 188 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {formatPrice} from '../lib/helpers';
import {loadListing} from '../lib/api';
export default class Listings extends React.Component {
constructor(props) {
@@ -32,12 +33,22 @@ export default class Listings extends React.Component {
}
onListingClick(id) {
this.props.dispatch({
type: 'VIEW_LISTING_DETAILS',
action: {
id
}
loadListing(id).then(l => l.text()).then(l => {
console.log('listing loaded', l);
this.props.dispatch({type: 'VIEW_LISTING_DETAILS', action: {
id,
listing: JSON.parse(l)
}});
});
//this.props.dispatch({
//type: 'VIEW_LISTING_DETAILS',
//action: {
//id
//}
//});
}
onMouseEnter (id) {