diff --git a/src/adapter/index.ts b/src/adapter/index.ts index 9e897a775..516cd96d3 100644 --- a/src/adapter/index.ts +++ b/src/adapter/index.ts @@ -1,4 +1,4 @@ -import { api, client, hasError, initialise, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api' +import { api, client, hasError, initialise, resetConfig, updateInstanceUrl, updateToken, getUserFacilities } from '@hotwax/oms-api' export { api, @@ -7,5 +7,6 @@ export { hasError, resetConfig, updateInstanceUrl, - updateToken + updateToken, + getUserFacilities } \ No newline at end of file diff --git a/src/authorization/Rules.ts b/src/authorization/Rules.ts index 5dc95f12b..6d5f374f8 100644 --- a/src/authorization/Rules.ts +++ b/src/authorization/Rules.ts @@ -4,5 +4,6 @@ export default { "APP_ORDER_DETAIL_VIEW": "", "APP_PRODUCT_DETAIL_VIEW": "", "APP_ORDER_UPDATE": "COMMON_ADMIN", - "APP_RF_CONFIG_UPDATE": "COMMON_ADMIN" + "APP_RF_CONFIG_UPDATE": "COMMON_ADMIN", + "APP_STOREFULFILLMENT_ADMIN": "STOREFULFILLMENT_ADMIN" } as any \ No newline at end of file diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 6259579ee..2b8ecf9c4 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -1,12 +1,13 @@ import { UserService } from '@/services/UserService' import { ActionTree } from 'vuex' import RootState from '@/store/RootState' +import store from '@/store'; import UserState from './UserState' import * as types from './mutation-types' import { showToast } from '@/utils' import i18n, { translate } from '@/i18n' import { DateTime, Settings } from 'luxon'; -import { hasError, updateInstanceUrl, updateToken, resetConfig } from '@/adapter' +import { hasError, updateInstanceUrl, updateToken, resetConfig, getUserFacilities } from '@/adapter' import { getServerPermissionsFromRules, prepareAppPermissions, @@ -61,6 +62,12 @@ const actions: ActionTree = { const userProfile = await UserService.getUserProfile(token); + //fetching user facilities + const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "APP_STOREFULFILLMENT_ADMIN" ); + const baseURL = store.getters['user/getBaseUrl']; + const facilities = await getUserFacilities(token, baseURL, userProfile?.partyId, "PICKUP", isAdminUser); + userProfile.facilities = facilities; + // removing duplicate records as a single user can be associated with a facility by multiple roles. userProfile.facilities.reduce((uniqueFacilities: any, facility: any, index: number) => { if(uniqueFacilities.includes(facility.facilityId)) userProfile.facilities.splice(index, 1); diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 7df5c4afe..c436a482b 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -64,7 +64,7 @@ {{ $t("Select facility") }} - {{ facility.name }} + {{ facility.facilityName }}