aretherecookies-mobile/js/enhancers/quantityEnhancers.js
Bart Akeley 8da242a11c require login for quantity updates and item creation
requires corresponding backend updates
2018-01-27 16:56:01 -06:00

18 lines
659 B
JavaScript

//@flow
import { withProps } from 'recompose';
import { setQuantity } from '../apis/QuantityApi';
import { emit as emitQuantity } from '../streams/QuantityStream';
import type { Quantity, QuantityResponse } from '../constants/QuantityConstants';
import { nth } from 'ramda';
export const withUpdateQuantity = withProps({
updateQuantity: async ({ foodItemId, quantity }: { foodItemId: string, quantity: Quantity }) => {
try {
const newQuantity: QuantityResponse = nth(0, await setQuantity({ foodItemId, quantity }));
emitQuantity(newQuantity);
} catch (error) {
// todo - error states in food item detail page
console.log(error);
}
},
});