aretherecookies-mobile/js/pages/Places.js
2017-07-23 19:58:10 -05:00

41 lines
1.2 KiB
JavaScript

// @flow
import React, { Component } from 'react';
import { View, ScrollView } from 'react-native';
import theme from '../ui-theme';
import PlaceTile from '../components/PlaceTile';
import { compose } from 'recompose';
import { withFoodItemsGroupedByPlace, withCategories, withDistance } from '../enhancers/foodItemEnhancers';
import { withPlace } from '../enhancers/placeEnhancers';
import { type Map } from 'immutable';
import typeof FoodItemRecord from '../records/FoodItemRecord';
const withPlaceProps = compose(withCategories, withDistance, withPlace);
const PlacesList = withFoodItemsGroupedByPlace(
({ foodItemsByPlace }: { foodItemsByPlace: Map<string, Map<string, FoodItemRecord>> }) => {
return (
<View>
{foodItemsByPlace
.map((foodItems: Map<string, FoodItemRecord>, placeId: string) => {
const EnhancedPlaceTile = withPlaceProps(PlaceTile);
return <EnhancedPlaceTile key={placeId} placeId={placeId} foodItems={foodItems} />;
})
.toList()}
</View>
);
}
);
export default class Places extends Component {
static displayName = 'Places';
render() {
return (
<View style={theme.page.container}>
<ScrollView>
<PlacesList />
</ScrollView>
</View>
);
}
}