Skip to content

Commit

Permalink
Merge pull request #277 from hotwax/store_admin_access/#146
Browse files Browse the repository at this point in the history
Improved: Added login support for the Store Fulfillment Admin User.
  • Loading branch information
ravilodhi authored Sep 18, 2023
2 parents 741ffb8 + 74fbe29 commit ff6bd59
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.1.0",
"@hotwax/dxp-components": "^1.3.4",
"@hotwax/oms-api": "^1.7.0",
"@hotwax/oms-api": "^1.10.0",
"@ionic/core": "6.7.5",
"@ionic/vue": "6.7.5",
"@ionic/vue-router": "6.7.5",
Expand Down
5 changes: 3 additions & 2 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -7,5 +7,6 @@ export {
hasError,
resetConfig,
updateInstanceUrl,
updateToken
updateToken,
getUserFacilities
}
3 changes: 2 additions & 1 deletion src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
@@ -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 { Settings } from 'luxon';
import { hasError, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import { hasError, updateInstanceUrl, updateToken, resetConfig, getUserFacilities } from '@/adapter'
import {
getServerPermissionsFromRules,
prepareAppPermissions,
Expand Down Expand Up @@ -54,6 +55,12 @@ const actions: ActionTree<UserState, RootState> = {

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);
Expand Down
2 changes: 1 addition & 1 deletion src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<ion-item lines="none">
<ion-label>{{ $t("Select facility") }}</ion-label>
<ion-select interface="popover" :value="currentFacility?.facilityId" @ionChange="setFacility($event)">
<ion-select-option v-for="facility in (userProfile ? userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.name }}</ion-select-option>
<ion-select-option v-for="facility in (userProfile ? userProfile.facilities : [])" :key="facility.facilityId" :value="facility.facilityId" >{{ facility.facilityName }}</ion-select-option>
</ion-select>
</ion-item>
</ion-card>
Expand Down

0 comments on commit ff6bd59

Please sign in to comment.