aretherecookies-mobile/js/enhancers/quantityEnhancers.js
Bart Akeley 9221b7f9b5 quantities round trip api and stream
make POST requests to /quantity to update the quantity of an existing food item - then mixin the new quantity with the existing food items observable
2017-11-26 19:52:16 -06:00

13 lines
527 B
JavaScript

//@flow
import { withProps } from 'recompose';
import { setQuantity } from '../apis/QuantityApi';
import { emit } 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 }) => {
const newQuantity: QuantityResponse = nth(0, await setQuantity({ foodItemId, quantity }));
emit(newQuantity);
},
});