Skip to content

Commit

Permalink
Improved: popover component name, conditions in getProductStores acti…
Browse files Browse the repository at this point in the history
…on (#10)
  • Loading branch information
amansinghbais committed Nov 17, 2023
1 parent 7f39d25 commit aada1d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ import { translate } from "@hotwax/dxp-components";
import { mapGetters, useStore } from "vuex";
import { FacilityService } from "@/services/FacilityService";
import { DateTime } from "luxon";
import { hasError } from "@hotwax/oms-api";
import { hasError } from "@/adapter";
import { showToast } from "@/utils";
import logger from "@/logger";
export default defineComponent({
name: "OpenStorePopover",
name: "ProductStorePopover",
components: {
IonContent,
IonList,
Expand Down Expand Up @@ -62,9 +63,11 @@ export default defineComponent({
// refetching product stores with updated roles
await this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId })
} else {
throw resp.data
}
} catch(err) {
console.error(err)
logger.error(err)
showToast(translate('Store unlink failed.'))
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/store/modules/facility/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const actions: ActionTree<FacilityState, RootState> = {
commit(types.FACILITY_LIST_UPDATED , { facilities: [], total: 0 });
},

async getFacilityProductStores({ commit, state }, params) {
async getFacilityProductStores({ commit }, params) {
let productStores = []
const payload = {
inputFields: {
Expand All @@ -158,13 +158,13 @@ const actions: ActionTree<FacilityState, RootState> = {
try {
const resp = await FacilityService.getFacilityProductStores(payload)

if (!hasError(resp) || resp.data.error === 'No record found') {
productStores = resp.data.docs ? resp.data.docs : []
if(!hasError(resp) && resp.data.count) {
productStores = resp.data.docs
} else {
throw resp.data
}
} catch (error) {
console.error('Failed to fetch user associated product stores.', error)
} catch(error) {
logger.error(error)
}

commit(types.FACILITY_PRODUCT_STORES_UPDATED , productStores);
Expand Down
8 changes: 4 additions & 4 deletions src/views/FacilityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
<h2>{{ getStoreDetail(store.productStoreId).storeName }}</h2>
</ion-label>
<ion-badge>{{ translate("primary store") }}</ion-badge>
<ion-button slot="end" fill="clear" color="medium" @click="openStorePopover($event, store)">
<ion-button slot="end" fill="clear" color="medium" @click="productStorePopover($event, store)">
<ion-icon slot="icon-only" :icon="ellipsisVerticalOutline" />
</ion-button>
</ion-item>
Expand Down Expand Up @@ -401,7 +401,7 @@ import {
import { translate } from '@hotwax/dxp-components';
import AddExternalMappingPopover from '@/components/AddExternalMappingPopover.vue'
import LocationDetailsPopover from '@/components/LocationDetailsPopover.vue';
import OpenStorePopover from '@/components/OpenStorePopover.vue';
import ProductStorePopover from '@/components/ProductStorePopover.vue';
import AddAddressModal from '@/components/AddAddressModal.vue'
import AddGeoPointModal from '@/components/AddGeoPointModal.vue';
import SelectProductStoreModal from '@/components/SelectProductStoreModal.vue'
Expand Down Expand Up @@ -462,9 +462,9 @@ export default defineComponent({
await this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId })
},
methods: {
async openStorePopover(ev: Event, store: any) {
async productStorePopover(ev: Event, store: any) {
const popover = await popoverController.create({
component: OpenStorePopover,
component: ProductStorePopover,
componentProps: {
facilityId: this.facilityId,
currentProductStore: store
Expand Down

0 comments on commit aada1d4

Please sign in to comment.