mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 07:34:55 -06:00
18 lines
681 B
JavaScript
18 lines
681 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 ({ productId, quantity }: { productId: string, quantity: Quantity }) => {
|
|
try {
|
|
const newQuantity: QuantityResponse = nth(0, await setQuantity({ productId, quantity }));
|
|
emitQuantity(newQuantity);
|
|
} catch (error) {
|
|
// todo - error states in food item detail page
|
|
console.error(error); // eslint-disable-line
|
|
}
|
|
},
|
|
});
|