Skip to content

Commit

Permalink
Improved: fetching ecomStores using local service and added entry in …
Browse files Browse the repository at this point in the history
…locale for dxp component text (hotwax#220)
  • Loading branch information
amansinghbais committed Dec 5, 2024
1 parent fd092fb commit c54056c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.": "A store represents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores selling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.",
"All": "All",
"App": "App",
"Apply": "Apply",
Expand All @@ -25,6 +26,7 @@
"Changes to the date time format will cause edits done to your PO to be reverted.": "Changes to the date time format will cause edits done to your PO to be reverted.",
"Configure date time format": "Configure date time format",
"Check sample": "Check sample",
"Choosing a product identifier allows you to view products with your preferred identifiers.": "Choosing a product identifier allows you to view products with your preferred identifiers.",
"Click the backdrop to dismiss.": "Click the backdrop to dismiss.",
"Completed": "Completed",
"Confirm": "Confirm",
Expand Down Expand Up @@ -123,9 +125,12 @@
"Please upload a valid reset inventory csv to continue": "Please upload a valid reset inventory csv to continue",
"PO External Order ID": "PO External Order ID",
"Preorder": "Preorder",
"Primary": "Primary",
"Product Identification": "Product Identification",
"Product Identifier": "Product Identifier",
"Product SKU": "Product SKU",
"Product store": "Product store",
"Product Store": "Product Store",
"Product not found": "Product not found",
"Purchase order": "Purchase order",
"Purchase orders": "Purchase orders",
Expand Down Expand Up @@ -154,12 +159,14 @@
"Search": "Search",
"Search products": "Search products",
"Search time zones": "Search time zones",
"Secondary": "Secondary",
"Seems like uploaded file has missing products, checked with initial records.": "Seems like uploaded file has missing products, checked with initial {initialCount} records.",
"Schedule": "Schedule",
"Select": "Select",
"Select mapping": "Select mapping",
"Select SKU": "Select SKU",
"Select all the fields to continue": "Select all the fields to continue",
"Select store": "Select store",
"Select time zone": "Select time zone",
"Select time": "Select time",
"Select the column index for the following information in the uploaded CSV.": "Select the column index for the following information in the uploaded CSV.",
Expand All @@ -180,6 +187,7 @@
"Shopify product UPC": "Shopify product UPC",
"Start with Ionic": "Start with Ionic",
"STAY": "STAY",
"Store": "Store",
"store name": "store name",
"The inventory has been updated successfully": "The inventory has been updated successfully",
"The PO has been uploaded successfully": "The PO has been uploaded successfully",
Expand Down
36 changes: 36 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { api, client } from '@/adapter'
import store from '@/store';
import { hasError } from '@/adapter';
import logger from '@/logger';

const login = async (username: string, password: string): Promise <any> => {
return api({
Expand Down Expand Up @@ -141,10 +142,45 @@ const getUserPermissions = async (payload: any, token: any): Promise<any> => {
}
}

async function getEComStores(token: any): Promise<any> {
const baseURL = store.getters['user/getBaseUrl'];

const params = {
"viewSize": 200,
"fieldList": ["productStoreId", "storeName"],
"entityName": "ProductStoreFacilityDetail",
"distinct": "Y",
"noConditionFind": "Y",
"filterByDate": 'Y',
};

try {
const resp = await client({
url: "performFind",
method: "get",
baseURL,
params,
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json'
}
});
if(resp.status === 200 && !hasError(resp)) {
return Promise.resolve(resp.data.docs?.length ? resp.data.docs : []);
} else {
throw resp.data
}
} catch(error) {
logger.error(error)
return Promise.resolve({})
}
}

export const UserService = {
createFieldMapping,
deleteFieldMapping,
login,
getEComStores,
getFieldMappings,
getProfile,
getUserPermissions,
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const actions: ActionTree<UserState, RootState> = {
await dispatch('getProfile')
dispatch('setPreferredDateTimeFormat', process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy');

await useUserStore().getEComStoresByFacility("")
const ecomStores = await UserService.getEComStores(token)
useUserStore().$state.eComStores = ecomStores
await useUserStore().getEComStorePreference("SELECTED_BRAND")
const preferredStore: any = useUserStore().getCurrentEComStore

Expand Down

0 comments on commit c54056c

Please sign in to comment.