aretherecookies-mobile/js/modals/QuantityModal.js
2019-06-22 15:48:52 +00:00

37 lines
962 B
JavaScript

// @flow
import React from 'react';
import { getQuantityDropdownText } from '../helpers/QuantityHelpers';
import { type Quantity, QUANTITIES } from '../constants/QuantityConstants';
import FullScreenModal from './FullScreenModal';
import { typeof FoodItem } from '../records/FoodItemRecord';
import PickerItemRow from '../components/PickerItemRow';
type Props = {
onClose: () => void,
foodItem: FoodItem,
onUpdate: (q: Quantity) => void,
};
const QuantityModal = (props: Props) => {
const { foodItem, onUpdate, onClose } = props;
const onPress = (q: Quantity) => () => {
onUpdate(q);
onClose();
};
return (
<FullScreenModal title="Quantity" onClose={onClose}>
{QUANTITIES.map((quantity: Quantity) => (
<PickerItemRow
key={quantity}
text={getQuantityDropdownText(quantity)}
isSelected={quantity === foodItem.quantity}
onPress={onPress(quantity)}
/>
))}
</FullScreenModal>
);
};
export default QuantityModal;