|
113 | 113 | </ion-card-content>
|
114 | 114 | <ion-item lines="none">
|
115 | 115 | <ion-label>{{ translate("Sell online") }}</ion-label>
|
116 |
| - <ion-toggle :disabled="!hasPermission(Actions.APP_UPDT_ECOM_INV_CONFIG) || !isEComInvEnabled" v-model="isEComInvEnabled" @click="updateEComInvStatus($event)" slot="end" /> |
| 116 | + <ion-toggle :disabled="!hasPermission(Actions.APP_UPDT_ECOM_INV_CONFIG) || (!isEComInvEnabled && !facilityPreferredInvGroups)" v-model="isEComInvEnabled" @click="updateEComInvStatus($event)" slot="end" /> |
117 | 117 | </ion-item>
|
118 |
| - <ion-list v-if="isEComInvEnabled"> |
| 118 | + <ion-list v-if="isEComInvEnabled || facilityPreferredInvGroups.length"> |
119 | 119 | <ion-item-divider color="light">
|
120 | 120 | <ion-label>{{ translate("Channels") }}</ion-label>
|
121 | 121 | </ion-item-divider>
|
122 | 122 | <ion-item lines="none">
|
123 | 123 | <ion-row>
|
124 |
| - <ion-chip v-for="group in facilityInventoryGroups" :key="group.facilityId"> |
| 124 | + <ion-chip v-for="group in facilityInventoryGroups.length ? facilityInventoryGroups : facilityPreferredInvGroups" :key="group.facilityId"> |
125 | 125 | {{ group.facilityGroupName }}
|
126 | 126 | </ion-chip>
|
127 | 127 | </ion-row>
|
@@ -271,7 +271,8 @@ export default defineComponent({
|
271 | 271 | orderLimitType: 'unlimited',
|
272 | 272 | fulfillmentOrderLimit: "" as number | string,
|
273 | 273 | facilityInventoryGroups: [] as any,
|
274 |
| - isEComInvEnabled: false |
| 274 | + isEComInvEnabled: false, |
| 275 | + facilityPreferredInvGroups: [] as any |
275 | 276 | };
|
276 | 277 | },
|
277 | 278 | computed: {
|
@@ -377,6 +378,24 @@ export default defineComponent({
|
377 | 378 | } catch (err) {
|
378 | 379 | logger.error('Failed to fetch eCom inventory config', err)
|
379 | 380 | }
|
| 381 | +
|
| 382 | + try { |
| 383 | + if(!this.isEComInvEnabled) { |
| 384 | + resp = await UserService.fetchFacilityPreferredInvGroups({ |
| 385 | + facilityId: this.currentFacility.facilityId, |
| 386 | + oms: this.instanceUrl, |
| 387 | + collection: 'FACILITY_PREFERENCE' |
| 388 | + }) |
| 389 | +
|
| 390 | + if(!hasError(resp)) { |
| 391 | + this.facilityPreferredInvGroups = resp.data.docs |
| 392 | + } else { |
| 393 | + throw resp.data |
| 394 | + } |
| 395 | + } |
| 396 | + } catch(err) { |
| 397 | + logger.error(err) |
| 398 | + } |
380 | 399 | },
|
381 | 400 | logout () {
|
382 | 401 | this.store.dispatch('user/logout', { isUserUnauthorised: false }).then((redirectionUrl) => {
|
@@ -470,7 +489,7 @@ export default defineComponent({
|
470 | 489 | await this.getEcomInvStatus()
|
471 | 490 | },
|
472 | 491 | async addFacilityInvGroups() {
|
473 |
| - const addResponses = await Promise.allSettled(this.facilityInventoryGroups |
| 492 | + const addResponses = await Promise.allSettled(this.facilityPreferredInvGroups |
474 | 493 | .map(async (payload: any) => await UserService.addFacilityToGroup({
|
475 | 494 | "facilityId": this.currentFacility.facilityId,
|
476 | 495 | "facilityGroupId": payload.facilityGroupId
|
|
0 commit comments