mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 07:14:55 -06:00
the backend is now returning quantity data merged into the food item record, so this is an easy UI update to surface it from the REST response
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
// @flow
|
|
import React from 'react';
|
|
import { View } from 'react-native';
|
|
import { pure } from 'recompose';
|
|
import FoodItemRecord from '../records/FoodItemRecord';
|
|
import typeof PlaceRecord from '../records/PlaceRecord';
|
|
import theme from '../ui-theme';
|
|
import { Link } from 'react-router-native';
|
|
import { routeWithTitle } from '../helpers/RouteHelpers';
|
|
import { TileBox, StrongText, SubText, Thumbnail, QuantityLine } from './ItemTile';
|
|
import { withPlace } from '../enhancers/placeEnhancers';
|
|
|
|
const PlaceNameAndDistance = withPlace(({ place = {}, distance = 999.9 }: { place: PlaceRecord, distance: number }) => {
|
|
return <SubText>{`${place.name || 'Loading...'} - ${parseFloat(distance).toFixed(1)} mi`}</SubText>;
|
|
});
|
|
|
|
export default pure(({ foodItem }: { foodItem: FoodItemRecord }) => {
|
|
if (!foodItem) {
|
|
return <View />;
|
|
}
|
|
|
|
return (
|
|
<Link
|
|
to={routeWithTitle(`/foodItem/${foodItem.id || ''}`, foodItem.name)}
|
|
underlayColor={theme.itemTile.pressHighlightColor}
|
|
>
|
|
<View>
|
|
<TileBox>
|
|
<Thumbnail thumb={foodItem.thumbImage} />
|
|
<View>
|
|
<StrongText>{foodItem.name || ''}</StrongText>
|
|
<PlaceNameAndDistance placeId={foodItem.placeId} distance={foodItem.distance} />
|
|
<QuantityLine quantity={foodItem.quantity} lastupdated={foodItem.lastupdated} />
|
|
</View>
|
|
</TileBox>
|
|
</View>
|
|
</Link>
|
|
);
|
|
});
|