diff --git a/src/locales/en.json b/src/locales/en.json index 600dfa77..c8dc9b17 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -8,6 +8,7 @@ "Are you sure you have received the purchase order for the selected items? Once closed, the shipments for the selected items wont be available for receiving later.": "Are you sure you have received the purchase order for the selected items? { space } Once closed, the shipments for the selected items won't be available for receiving later.", "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?", "Arrival date": "Arrival date", + "Back to Launchpad": "Back to Launchpad", "Cancel": "Cancel", "Change": "Change", "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.", @@ -21,6 +22,8 @@ "Close purchase order items": "Close purchase order items", "eCom Store": "eCom Store", "Enter a custom date time format that you want to use when uploading documents to HotWax Commerce.": "Enter a custom date time format that you want to use when uploading documents to HotWax Commerce.", + "Error getting preferred product store.": "Error getting preferred product store.", + "Error getting user profile.": "Error getting user profile.", "External ID": "External ID", "Facility": "Facility", "Location": "Location", @@ -41,6 +44,7 @@ "Load more purchase order": "Load more purchase order", "Loading": "Loading", "Login": "Login", + "Login failed": "Login failed", "Logging in": "Logging in", "Logging out": "Logging out", "Logout": "Logout", @@ -68,6 +72,7 @@ "Purchase Order Details": "Purchase Order Details", "Purchase Orders": "Purchase Orders", "Qty": "Qty", + "Reason:": "Reason:", "Receive": "Receive", "Receive All": "Receive All", "Receive And Close": "Receive And Close", @@ -107,6 +112,7 @@ "Shipped": "Shipped", "Shop eCommerce": "Shop eCommerce", "Something went wrong": "Something went wrong", + "Something went wrong while getting complete user permissions.": "Something went wrong while getting complete user permissions.", "Something went wrong while login. Please contact administrator": "Something went wrong while login. Please contact administrator.", "Sorry, your username or password is incorrect. Please try again.": "Sorry, your username or password is incorrect. Please try again.", "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.", @@ -123,6 +129,8 @@ "To close the purchase order, select all.": "To close the purchase order, select all.", "Unable to update product identifier preference": "Unable to update product identifier preference", "Update time zone": "Update time zone", + "User is not associated with any facilities.": "User is not associated with any facilities.", + "User is not associated with any product stores.": "User is not associated with any product stores.", "Username": "Username", "You do not have permission to access this page": "You do not have permission to access this page", "ZeroQuantity": "ZeroQuantity" diff --git a/src/router/index.ts b/src/router/index.ts index 03fb160d..3da18a0f 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -15,7 +15,7 @@ import { showToast } from '@/utils' import { translate } from '@/i18n' import 'vue-router' -import { Login, useAuthStore } from '@hotwax/dxp-components'; +import { DxpLogin, useAuthStore } from '@hotwax/dxp-components'; import { loader } from '@/user-utils'; // Defining types for the meta values @@ -71,7 +71,7 @@ const routes: Array = [ { path: '/login', name: 'Login', - component: Login, + component: DxpLogin, beforeEnter: loginGuard }, { diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 1c960868..bbf2e645 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -35,8 +35,8 @@ const getUserProfile = async (token: any): Promise => { 'Content-Type': 'application/json' } }); - if(hasError(resp)) return Promise.reject("Error getting user profile: " + JSON.stringify(resp.data)); - if(resp.data.facilities.length === 0) return Promise.reject("User is not associated with any facilities: " + JSON.stringify(resp.data)); + if (hasError(resp)) return Promise.reject({ message: "Error getting user profile." }); + if (resp.data.facilities.length === 0) return Promise.reject({ message: "User is not associated with any facilities." }); return Promise.resolve(resp.data) } catch(error: any) { return Promise.reject(error) @@ -91,7 +91,7 @@ const getEComStores = async (token: any, facilityId: any): Promise => { }); // Disallow login if the user is not associated with any product store if (hasError(resp) || resp.data.docs.length === 0) { - return Promise.reject(resp.data); + return Promise.reject({ message: "User is not associated with any product stores." }); } else { return Promise.resolve(resp.data.docs); } @@ -124,7 +124,7 @@ const getPreferredStore = async (token: any): Promise => { } }); if (hasError(resp)) { - return Promise.reject(resp.data); + return Promise.reject({ message: "Error getting preferred product store." }); } return Promise.resolve(resp.data.userPrefValue); } catch(error: any) { @@ -210,11 +210,11 @@ const getUserPermissions = async (payload: any, token: any): Promise => { 'Content-Type': 'application/json' } }) - if(!hasError(response)){ + if (!hasError(response)) { return Promise.resolve(response); - } else { - return Promise.reject(response); - } + } else { + return Promise.reject({ message: "Something went wrong while getting complete user permissions." }); + } })) const permissionResponses = { success: [], @@ -238,7 +238,7 @@ const getUserPermissions = async (payload: any, token: any): Promise => { // Show toast to user intimiting about the failure // Allow user to login // TODO Implement Retry or improve experience with show in progress icon and allowing login only if all the data related to user profile is fetched. - if (permissionResponses.failed.length > 0) Promise.reject("Something went wrong while getting complete user permissions."); + if (permissionResponses.failed.length > 0) Promise.reject({ message: "Something went wrong while getting complete user permissions." }); } } return serverPermissions; diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index fe117723..d2a16a11 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -49,7 +49,7 @@ const actions: ActionTree = { const permissionError = 'You do not have permission to access the app.'; showToast(translate(permissionError)); console.error("error", permissionError); - return Promise.reject(new Error(permissionError)); + return Promise.reject({ message: permissionError }); } } @@ -97,7 +97,7 @@ const actions: ActionTree = { // TODO Check if handling of specific status codes is required. showToast(translate('Something went wrong while login. Please contact administrator')); console.error("error", err); - return Promise.reject(new Error(err)) + return Promise.reject(err) } },