From f819a5bd8721b283a9b896f06eb6a1905bed4d76 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Mon, 16 Dec 2024 12:33:49 +0530 Subject: [PATCH] Implemented: service to fetch orders and service to broker order(#254) --- src/services/ProductService.ts | 39 ++++++++++++++++++++++++++++ src/services/RoutingService.ts | 46 +++++++++++++++++++++++++++++++++- src/store/index.ts | 6 +++-- 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 src/services/ProductService.ts diff --git a/src/services/ProductService.ts b/src/services/ProductService.ts new file mode 100644 index 0000000..ed4784a --- /dev/null +++ b/src/services/ProductService.ts @@ -0,0 +1,39 @@ +import { client } from "@/api"; +import store from "@/store"; + +const fetchProducts = async (payload: any): Promise => { + 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 => { + 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 +} \ No newline at end of file diff --git a/src/services/RoutingService.ts b/src/services/RoutingService.ts index 695581d..092b908 100644 --- a/src/services/RoutingService.ts +++ b/src/services/RoutingService.ts @@ -1,4 +1,5 @@ -import api from "@/api" +import api, { client } from "@/api" +import store from "@/store"; const fetchRoutingGroups = async (payload: any): Promise => { return api({ @@ -163,7 +164,48 @@ const runNow = async (routingGroupId: string): Promise => { }); } +const findOrder = async (payload: any): Promise => { + 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 => { + return api({ + url: `groups/${payload.routingGroupId}/run`, + method: "POST", + data: payload + }) +} + +const getOrderFacilityChangeInfo = async (payload: any): Promise => { + 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, @@ -180,6 +222,8 @@ export const OrderRoutingService = { fetchRoutingHistory, fetchRoutingScheduleInformation, fetchRule, + findOrder, + getOrderFacilityChangeInfo, runNow, scheduleBrokering, updateRouting, diff --git a/src/store/index.ts b/src/store/index.ts index 83e5c43..5adab0d 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -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 @@ -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 }) @@ -30,7 +31,8 @@ const store = createStore({ modules: { "user": userModule, "util": utilModule, - "orderRouting": orderRoutingModule + "orderRouting": orderRoutingModule, + "product": productModule }, })