Handle additional orders info for wiaas
This commit is contained in:
@@ -56,14 +56,18 @@ export const receiveCustomerDetails = (json) => ({
|
||||
|
||||
export const fetchCartCount = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestShopCartCount());
|
||||
//TODO : fetch cart count from woocommerce (requires plugin)
|
||||
dispatch(receiveShopCartCount(0));
|
||||
/*return client.fetch({url: `${API_SERVER}/cart/api/getCartCount`}).then(response => {
|
||||
/*
|
||||
return client.fetch({url: `${API_SERVER}/cart/api/getCartCount`}).then(response => {
|
||||
if (typeof response.data !== 'undefined' && 'cartItemsCount' in response.data) {
|
||||
dispatch(receiveShopCartCount(response.data.cartItemsCount));
|
||||
}
|
||||
}).catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});*/
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {API_SERVER} from '../../config';
|
||||
import HtmlClient from '../../helpers/HtmlClient';
|
||||
import {REQUEST_GADGETS, RECIEVE_GADGETS} from '../../constants/dashboardConstants';
|
||||
const htmlClient = new HtmlClient();
|
||||
|
||||
const requestGadgets = () => ({type: REQUEST_GADGETS});
|
||||
const recieveGadgets = (json) => ({
|
||||
@@ -12,7 +9,30 @@ const recieveGadgets = (json) => ({
|
||||
export const fetchGadgets = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestGadgets());
|
||||
const data = {"info":{"idDashboard":"23","name":"Customer Basic Dashboard","isOwner":"0"},"gadgets":[{"idGadget":"3","name":"Customer Order Central","module":"gadget-order-central","position":"1"},{"idGadget":"5","name":"Customer Next Actions","module":"gadget-next-actions","position":"2"}]};
|
||||
dispatch(recieveGadgets(data.gadgets))
|
||||
//TODO : check how to solve gadgets, don't use hardcoded values
|
||||
const gadgets = [
|
||||
{
|
||||
name: 'CustomerOrderCentral',
|
||||
idGadget: 0,
|
||||
},
|
||||
{
|
||||
name: 'CustomerNextActions',
|
||||
idGadget: 1,
|
||||
}
|
||||
]
|
||||
dispatch(recieveGadgets(gadgets));
|
||||
/*
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/dashboards/api/getMyDashboard`
|
||||
})
|
||||
.then(response => {
|
||||
if(response.data && response.data.gadgets){
|
||||
dispatch(recieveGadgets(response.data.gadgets))
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {API_SERVER} from '../../config';
|
||||
import HtmlClient from '../../helpers/HtmlClient';
|
||||
import {REQUEST_NEXT_ACTIONS, RECIEVE_NEXT_ACTIONS} from '../../constants/dashboardConstants';
|
||||
import { API_SERVER } from '../../config';
|
||||
import HtmlClient from '../../helpers/HtmlClient';
|
||||
|
||||
const client = new HtmlClient();
|
||||
|
||||
export const requestNextActions = () => ({
|
||||
@@ -23,6 +24,6 @@ export const fetchNextActions = () => {
|
||||
.then(response => dispatch(recieveNextActions(response.data)))
|
||||
.catch(error => {
|
||||
client.onError(error, dispatch);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
REQUEST_ORDERS,
|
||||
RECEIVE_ORDERS
|
||||
} from '../../constants/dashboardConstants';
|
||||
import {fromWCOrder} from '../../helpers/OrderHelper';
|
||||
import { MAX_ORDER_COUNT } from '../../constants/ordersConstants';
|
||||
const htmlClient = new HtmlClient();
|
||||
|
||||
export const requestOrders = () => ({
|
||||
@@ -19,17 +21,16 @@ export const recieveOrders = (json) => ({
|
||||
|
||||
export const fetchOrders = (viewAllOrders) => {
|
||||
return dispatch => {
|
||||
dispatch(recieveOrders([]));
|
||||
/*return htmlClient.fetch({
|
||||
url: `${API_SERVER}/dashboards/api/getOrderCentralInfo`,
|
||||
method: 'post',
|
||||
data: {
|
||||
viewAllOrders
|
||||
}
|
||||
dispatch(requestOrders());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?per_page=${MAX_ORDER_COUNT}&wiaas_is_active=1`,
|
||||
method: 'get',
|
||||
})
|
||||
.then(response => {
|
||||
dispatch(recieveOrders(response.data.map(wcOrder => fromWCOrder(wcOrder))));
|
||||
})
|
||||
.then(response => dispatch(recieveOrders(response.data)))
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
});*/
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,68 +160,70 @@ const validateRefreshToken = () => {
|
||||
|
||||
export const getModules = () => {
|
||||
return dispatch => {
|
||||
const data = {
|
||||
"modules": {
|
||||
"modules": [
|
||||
dispatch(requestModules());
|
||||
//TODO : check how to solve modules, don't hardocde values
|
||||
const modules={
|
||||
modules:{
|
||||
modules:[
|
||||
{
|
||||
"id": "14",
|
||||
"name": "ProfileSettings",
|
||||
"menuName": "ProfileSettings",
|
||||
"url": "profileSettings",
|
||||
"isInMenu": "0"
|
||||
id:"19",
|
||||
isInMenu:"0",
|
||||
menuName:"Cart",
|
||||
name:"Cart",
|
||||
url:"cart",
|
||||
|
||||
},
|
||||
{
|
||||
"id": "23",
|
||||
"name": "OrderProjects",
|
||||
"menuName": "OrderProjects",
|
||||
"url": "orderProjects",
|
||||
"isInMenu": "0"
|
||||
id:"14",
|
||||
isInMenu:"0",
|
||||
menuName:"ProfileSettings",
|
||||
name:"ProfileSettings",
|
||||
url:"profileSettings",
|
||||
},
|
||||
{
|
||||
"id": "15",
|
||||
"name": "Terms",
|
||||
"menuName": "Terms",
|
||||
"url": "terms",
|
||||
"isInMenu": "0"
|
||||
id:"23",
|
||||
isInMenu:"0",
|
||||
menuName:"OrderProjects",
|
||||
name:"OrderProjects",
|
||||
url:"orderProjects",
|
||||
},
|
||||
{
|
||||
"id": "19",
|
||||
"name": "Cart",
|
||||
"menuName": "Cart",
|
||||
"url": "cart",
|
||||
"isInMenu": "0"
|
||||
id:"15",
|
||||
isInMenu:"0",
|
||||
menuName:"Terms",
|
||||
name:"Terms",
|
||||
url:"terms",
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Dashboards",
|
||||
"menuName": "Overview",
|
||||
"url": "dashboards",
|
||||
"isInMenu": "1"
|
||||
id:"1",
|
||||
isInMenu:"1",
|
||||
menuName:"Overview",
|
||||
name:"Dashboards",
|
||||
url:"dashboards",
|
||||
},
|
||||
{
|
||||
"id": "18",
|
||||
"name": "CoMarket",
|
||||
"menuName": "Co-Market",
|
||||
"url": "co-market",
|
||||
"isInMenu": "1"
|
||||
id:"18",
|
||||
isInMenu:"1",
|
||||
menuName:"Co-Market",
|
||||
name:"CoMarket",
|
||||
url:"co-market",
|
||||
}
|
||||
],
|
||||
"subModules": {
|
||||
"co-market": [
|
||||
subModules:{
|
||||
"co-market":[
|
||||
{
|
||||
"moduleUrl": "co-market",
|
||||
"menuName": "Orders",
|
||||
"name": "Orders",
|
||||
"url": "orders"
|
||||
menuName:"Orders",
|
||||
name:"Orders",
|
||||
url:"orders",
|
||||
moduleUrl:"co-market",
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
dispatch(recieveModules(data));
|
||||
|
||||
dispatch(requestModules());
|
||||
/**return htmlClient.fetch({
|
||||
}
|
||||
dispatch(recieveModules(modules));
|
||||
/*
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/login/api/getModules`,
|
||||
})
|
||||
.then(response => {
|
||||
@@ -229,7 +231,8 @@ export const getModules = () => {
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
});**/
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,14 @@ import {
|
||||
RECEIVE_HISTORY_ORDERS,
|
||||
SET_VIEW_ALL_ORDERS
|
||||
} from '../../constants/ordersConstants';
|
||||
import {fromWCOrder} from '../../helpers/OrderHelper';
|
||||
const htmlClient = new HtmlClient();
|
||||
|
||||
const requestActiveOrders = () => ({
|
||||
type: REQUEST_ACTIVE_ORDERS,
|
||||
isLoading: true
|
||||
});
|
||||
const recieveActiveOrders = (json) => ({
|
||||
const receiveActiveOrders = (json) => ({
|
||||
type: RECEIVE_ACTIVE_ORDERS,
|
||||
isLoading: false,
|
||||
activeOrders: json
|
||||
@@ -23,10 +24,10 @@ export const getActiveOrders = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestActiveOrders());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?status=processing`
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?wiaas_is_active=1`
|
||||
})
|
||||
.then(response => {
|
||||
dispatch(recieveActiveOrders(response.data));
|
||||
dispatch(receiveActiveOrders(response.data.map(wcOrder => fromWCOrder(wcOrder))));
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
@@ -48,10 +49,10 @@ export const getHistoryOrders = () => {
|
||||
return dispatch => {
|
||||
dispatch(requestHistoryOrders());
|
||||
return htmlClient.fetch({
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?status=completed`
|
||||
url: `${API_SERVER}/wp-json/wc/v2/orders?wiaas_is_active=0`
|
||||
})
|
||||
.then(response => {
|
||||
dispatch(recieveHistoryOrders(response.data));
|
||||
dispatch(recieveHistoryOrders(response.data.map(wcOrder => fromWCOrder(wcOrder))));
|
||||
})
|
||||
.catch(error => {
|
||||
htmlClient.onError(error, dispatch);
|
||||
|
||||
Reference in New Issue
Block a user