Gallery and other stuff
This commit is contained in:
@@ -10,13 +10,20 @@ const viewListingDetails= ({type, action}, component) => {
|
||||
component.setState({
|
||||
listingDetails: true,
|
||||
listingId: action.id,
|
||||
descriptionExpanded: false
|
||||
descriptionExpanded: false,
|
||||
imageIndex: 0
|
||||
})
|
||||
}
|
||||
|
||||
const listingsLoaded = ({type, action}, component) => {
|
||||
const currentListings = component.state.listings;
|
||||
|
||||
for(const listing of action.listings) {
|
||||
currentListings.set(listing.url, listing)
|
||||
}
|
||||
|
||||
component.setState({
|
||||
listings: action.listings
|
||||
listings: currentListings
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,10 +33,35 @@ const expandDescription = ({type, action}, component) => {
|
||||
});
|
||||
}
|
||||
|
||||
const prevImage = ({type, action}, component) => {
|
||||
const index = component.state.imageIndex;
|
||||
if (index > 0) {
|
||||
component.setState({
|
||||
imageIndex: index - 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const nextImage = ({type, action}, component) => {
|
||||
const index = component.state.imageIndex;
|
||||
component.setState({
|
||||
imageIndex: index + 1
|
||||
});
|
||||
}
|
||||
|
||||
const viewImage = ({type, action}, component) => {
|
||||
component.setState({
|
||||
imageIndex: action.index
|
||||
});
|
||||
}
|
||||
|
||||
const handlers = {
|
||||
'SET_MIN_PRICE': setMinPrice,
|
||||
'LISTINGS_LOADED': listingsLoaded,
|
||||
'EXPAND_DESCRIPTION': expandDescription,
|
||||
'PREV_IMAGE': prevImage,
|
||||
'NEXT_IMAGE': nextImage,
|
||||
'VIEW_IMAGE': viewImage,
|
||||
'VIEW_LISTING_DETAILS': viewListingDetails
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user