Example #1
0
 return (dispatch, getState) => {
   return api.orders.updateShippingAddress(orderId, address)
   .then(orderResponse => orderResponse.json)
   .then(fetchOrderAdditionalData)
   .then(order => {
     dispatch(receiveOrder(order))
   })
   .catch(error => {});
 }
Example #2
0
 return (dispatch, getState) => {
   const state = getState();
   return api.orders.create({ draft: true, referrer_url: 'admin' }).then(orderResponse => {
     const orderId = orderResponse.json.id;
     dispatch(createOrdersSuccess());
     history.push(`/admin/order/${orderId}`);
   })
   .catch(error => {});
 }
Example #3
0
  return (dispatch, getState) => {
    const state = getState();
    let order = state.orders.editOrder;

    if(order && order.id) {
      return api.orders.delete(order.id)
      .catch(err => { console.log(err) });
    }
  }
Example #4
0
 return (dispatch, getState) => {
   return api.orders.cancel(orderId)
   .then(orderResponse => orderResponse.json)
   .then(fetchOrderAdditionalData)
   .then(order => {
     dispatch(receiveOrder(order))
   })
   .catch(error => {});
 }
Example #5
0
 return (dispatch, getState) => {
   dispatch(requestOrderCheckout());
   return api.orders.checkout(orderId)
   .then(orderResponse => orderResponse.json)
   .then(fetchOrderAdditionalData)
   .then(order => {
     dispatch(receiveOrderCheckout());
     dispatch(receiveOrder(order))
   })
   .catch(error => {
     dispatch(failOrderCheckout(error));
   });
 }
Example #6
0
  return (dispatch, getState) => {
    dispatch(requestOrderUpdate());

    return api.orders.update(data.id, data)
    .then(orderResponse => orderResponse.json)
    .then(fetchOrderAdditionalData)
    .then(order => {
      dispatch(receiveOrderUpdate());
      dispatch(receiveOrder(order))
    })
    .catch(error => {
      dispatch(failOrderUpdate(error));
    });
  }
Example #7
0
  return (dispatch, getState) => {
    const state = getState();
    if (!state.orders.loadingItems) {
      dispatch(requestMoreOrders());

      let filter = getFilter(state, state.orders.items.length);

      return api.orders.list(filter)
        .then(({status, json}) => {
          dispatch(receiveOrdersMore(json))
        })
        .catch(error => {
            dispatch(receiveOrdersError(error));
        });
    }
  }
Example #8
0
  return (dispatch, getState) => {
    const state = getState();
    if (!state.orders.loadingItems) {
      dispatch(requestOrders());
      dispatch(deselectAllOrder());

      let filter = getFilter(state);

      return api.orders.list(filter)
        .then(({status, json}) => {
          dispatch(receiveOrders(json))
        })
        .catch(error => {
            dispatch(receiveOrdersError(error));
        });
    }
  }
Example #9
0
	fetchData = () => {
		const filter = {
			draft: false,
			cancelled: false,
			date_placed_min: moment()
				.subtract(1, 'months')
				.hour(0)
				.minute(0)
				.second(0)
				.toISOString()
		};

		api.orders
			.list(filter)
			.then(({ status, json }) => {
				const reportData = utils.getReportDataFromOrders(json);
				const ordersData = utils.getOrdersDataFromReportData(reportData);
				const salesData = utils.getSalesDataFromReportData(reportData);
				this.setState({ ordersData, salesData });
			})
			.catch(error => {
				console.log(error);
			});
	};
Example #10
0
 let promises = state.orders.selected.map(orderId => api.orders.delete(orderId));
Example #11
0
 let promises = state.orders.selected.map(orderId => api.orders.update(orderId, dataToSet));