Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/bopis into bopis/not…
Browse files Browse the repository at this point in the history
…ifications-2
  • Loading branch information
k2maan committed Sep 18, 2023
2 parents be855f3 + ff6bd59 commit e858969
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
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 { DateTime, 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 @@ -61,6 +62,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 e858969

Please sign in to comment.