Skip to content

Commit

Permalink
Implemented: service to fetch orders and service to broker order(hotw…
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Dec 16, 2024
1 parent f8a1608 commit f819a5b
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 3 deletions.
39 changes: 39 additions & 0 deletions src/services/ProductService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { client } from "@/api";
import store from "@/store";

const fetchProducts = async (payload: any): Promise <any> => {
const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"];
let baseURL = omsRedirectionInfo.url;
baseURL = baseURL && baseURL.startsWith("http") ? baseURL : `https://${baseURL}.hotwax.io/api/`;
return client({
url: "searchProducts",
method: "post",
baseURL: baseURL,
data: payload,
headers: {
Authorization: 'Bearer ' + omsRedirectionInfo.token,
'Content-Type': 'application/json'
}
});
}

const getInventoryAvailableByFacility = async (payload: any): Promise <any> => {
const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"];
let baseURL = omsRedirectionInfo.url;
baseURL = baseURL && baseURL.startsWith("http") ? baseURL : `https://${baseURL}.hotwax.io/api/`;
return client({
url: "service/getInventoryAvailableByFacility",
method: "post",
baseURL: baseURL,
data: payload,
headers: {
Authorization: 'Bearer ' + omsRedirectionInfo.token,
'Content-Type': 'application/json'
}
});
}

export const ProductService = {
fetchProducts,
getInventoryAvailableByFacility
}
46 changes: 45 additions & 1 deletion src/services/RoutingService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import api from "@/api"
import api, { client } from "@/api"
import store from "@/store";

const fetchRoutingGroups = async (payload: any): Promise<any> => {
return api({
Expand Down Expand Up @@ -163,7 +164,48 @@ const runNow = async (routingGroupId: string): Promise<any> => {
});
}

const findOrder = async (payload: any): Promise<any> => {
const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"];
let baseURL = omsRedirectionInfo.url;
baseURL = baseURL && baseURL.startsWith("http") ? baseURL : `https://${baseURL}.hotwax.io/api/`;
return client({
url: "solr-query",
method: "post",
baseURL: baseURL,
data: payload,
headers: {
Authorization: 'Bearer ' + omsRedirectionInfo.token,
'Content-Type': 'application/json'
}
});
}

const brokerOrder = async(payload: any): Promise<any> => {
return api({
url: `groups/${payload.routingGroupId}/run`,
method: "POST",
data: payload
})
}

const getOrderFacilityChangeInfo = async (payload: any): Promise<any> => {
const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"];
let baseURL = omsRedirectionInfo.url;
baseURL = baseURL && baseURL.startsWith("http") ? baseURL : `https://${baseURL}.hotwax.io/api/`;
return client({
url: "performFind",
method: "post",
baseURL: baseURL,
data: payload,
headers: {
Authorization: 'Bearer ' + omsRedirectionInfo.token,
'Content-Type': 'application/json'
}
});
}

export const OrderRoutingService = {
brokerOrder,
cloneGroup,
createOrderRouting,
cloneRouting,
Expand All @@ -180,6 +222,8 @@ export const OrderRoutingService = {
fetchRoutingHistory,
fetchRoutingScheduleInformation,
fetchRule,
findOrder,
getOrderFacilityChangeInfo,
runNow,
scheduleBrokering,
updateRouting,
Expand Down
6 changes: 4 additions & 2 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import userModule from "./modules/user";
import utilModule from "./modules/util"
import orderRoutingModule from "./modules/orderRouting"
import { setPermissions } from "@/authorization"
import productModule from "./modules/product"

// TODO check how to register it from the components only
// Handle same module registering multiple time on page refresh
Expand All @@ -16,7 +17,7 @@ import { setPermissions } from "@/authorization"
const state: any = {}

const persistState = createPersistedState({
paths: ["user", "util", "orderRouting.currentGroup", "orderRouting.currentRuleId"],
paths: ["user", "util", "orderRouting.currentGroup", "orderRouting.currentRuleId", "product"],
fetchBeforeUse: true
})

Expand All @@ -30,7 +31,8 @@ const store = createStore<RootState>({
modules: {
"user": userModule,
"util": utilModule,
"orderRouting": orderRoutingModule
"orderRouting": orderRoutingModule,
"product": productModule
},
})

Expand Down

0 comments on commit f819a5b

Please sign in to comment.