mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 09:44:55 -06:00
37 lines
962 B
JavaScript
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;
|