aretherecookies-mobile/js/helpers/QuantityHelpers.js
Bart Akeley f9832afb2e show quantity and last updated in food item list
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
2017-11-19 12:22:09 -06:00

25 lines
645 B
JavaScript

// @flow
import { type Quantity } from '../constants/QuantityConstants';
const quantityLabels: { [Quantity]: string } = {
none: 'None left',
few: 'A few left',
lots: 'A lot left',
many: 'Plenty left',
};
export const getQuantityLabelText = (quantity: Quantity) => quantityLabels[quantity] || quantityLabels['many'];
export const getQuantityDropdownText = (quantity: Quantity) => {
const label = quantityLabels[quantity];
switch (quantity) {
case 'none':
return `${label} - 0`;
case 'few':
return `${label} - 6 or fewer`;
case 'lots':
return `${label} - 10 or fewer`;
default:
return `${label} - more than 10`;
}
};