aretherecookies-mobile/js/helpers/CategoryHelpers.js
2017-11-11 20:15:19 -06:00

25 lines
673 B
JavaScript

// @flow
import FoodItemRecord from '../records/FoodItemRecord';
import { type Category, CATEGORY_BEVERAGES, CATEGORY_DESSERTS, CATEGORY_ENTREES } from '../constants/CategoryConstants';
import { type Map } from 'immutable';
export const getCategoryText = (category: Category) => {
switch (category) {
case CATEGORY_BEVERAGES:
return 'Beverages';
case CATEGORY_DESSERTS:
return 'Desserts';
case CATEGORY_ENTREES:
return 'Entrees';
default:
return 'Other';
}
};
export const getCategories = (foodItems: Map<string, FoodItemRecord>) => {
return foodItems
.toSet()
.map(foodItem => foodItem.get('category'))
.map(getCategoryText)
.toList();
};