mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 07:54:57 -06:00
14 lines
527 B
JavaScript
14 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);
|
||
|
|
},
|
||
|
|
});
|