aretherecookies-mobile/js/pages/Places.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-03-05 18:09:01 -06:00
// @flow
import React, { Component } from 'react';
2017-03-27 20:48:31 -05:00
import { View, ScrollView } from 'react-native';
2017-03-05 18:09:01 -06:00
import theme from '../ui-theme';
2017-07-02 17:55:00 -05:00
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';
2017-03-05 18:09:01 -06:00
2017-07-02 17:55:00 -05:00
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) => {
2017-07-23 19:58:10 -05:00
const EnhancedPlaceTile = withPlaceProps(PlaceTile);
return <EnhancedPlaceTile key={placeId} placeId={placeId} foodItems={foodItems} />;
2017-07-02 17:55:00 -05:00
})
.toList()}
</View>
);
}
);
2017-03-05 18:09:01 -06:00
export default class Places extends Component {
2017-07-02 17:55:00 -05:00
static displayName = 'Places';
2017-03-05 18:09:01 -06:00
2017-07-02 17:55:00 -05:00
render() {
return (
<View style={theme.page.container}>
<ScrollView>
<PlacesList />
</ScrollView>
</View>
);
}
2017-03-05 18:09:01 -06:00
}