-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented: functionality to product store card on facility details page (#10) #14
Conversation
src/components/OpenStorePopover.vue
Outdated
import { mapGetters, useStore } from "vuex"; | ||
import { FacilityService } from "@/services/FacilityService"; | ||
import { DateTime } from "luxon"; | ||
import { hasError } from "@hotwax/oms-api"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import from adapter instead of importing from oms-api
src/components/OpenStorePopover.vue
Outdated
import { FacilityService } from "@/services/FacilityService"; | ||
import { DateTime } from "luxon"; | ||
import { hasError } from "@hotwax/oms-api"; | ||
import { showToast } from "@/utils"; | ||
|
||
export default defineComponent({ | ||
name: "OpenStorePopover", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: "OpenStorePopover", | |
name: "ProductStorePopover", |
src/components/OpenStorePopover.vue
Outdated
await this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId }) | ||
} | ||
} catch(err) { | ||
console.error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use logger instead of console.
src/components/OpenStorePopover.vue
Outdated
|
||
// refetching product stores with updated roles | ||
await this.store.dispatch('facility/getFacilityProductStores', { facilityId: this.facilityId }) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of error throw resp.data
from else section.
@@ -141,6 +141,33 @@ const actions: ActionTree<FacilityState, RootState> = { | |||
facilityTypeId: '' | |||
}) | |||
commit(types.FACILITY_LIST_UPDATED , { facilities: [], total: 0 }); | |||
}, | |||
|
|||
async getFacilityProductStores({ commit, state }, params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused params.
try { | ||
const resp = await FacilityService.getFacilityProductStores(payload) | ||
|
||
if (!hasError(resp) || resp.data.error === 'No record found') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to check for exact error message explicitly, hasError method already checks for error in resp. Instead check for resp.data.count field.
const resp = await FacilityService.getFacilityProductStores(payload) | ||
|
||
if (!hasError(resp) || resp.data.error === 'No record found') { | ||
productStores = resp.data.docs ? resp.data.docs : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use ternary, as we will already check whether the resp has some data or not, using count param
throw resp.data | ||
} | ||
} catch (error) { | ||
console.error('Failed to fetch user associated product stores.', error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unwanted console statements
src/views/FacilityDetails.vue
Outdated
@@ -140,27 +140,17 @@ | |||
<ion-card-title> | |||
{{ translate("Product Stores") }} | |||
</ion-card-title> | |||
<ion-button @click="addProductStore" fill="clear"> | |||
<ion-button @click="selectProductStore()" fill="clear"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<ion-button @click="selectProductStore()" fill="clear"> | |
<ion-button @click="selectProductStores()" fill="clear"> |
src/views/FacilityDetails.vue
Outdated
|
||
const hasFailedResponse = [...updateResponses, ...createResponses].some((response: any) => response.status === 'rejected') | ||
if(hasFailedResponse) { | ||
showToast(translate('Failed to update some facility stores')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
showToast(translate('Failed to update some facility stores')) | |
showToast(translate('Failed to update product stores')) |
src/views/FacilityDetails.vue
Outdated
this.removeProductFromPrimaryMember() | ||
} | ||
}) | ||
showToast(translate('Facility stores updated successfully.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
showToast(translate('Facility stores updated successfully.')) | |
showToast(translate('Product stores updated successfully.')) |
"facilityId": this.facilityId, | ||
"facilityGroupId": this.primaryMember.facilityGroupId, | ||
"fromDate": this.primaryMember.fromDate, | ||
"thruDate": DateTime.now().toMillis() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle case when having error in the resp.
IonContent, | ||
IonList, | ||
IonListHeader, | ||
IonIcon, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arrange imports in alphabetical order.
Related Issues
Closes #10
Short Description and Why It's Useful
Made product store card dynamic and functional on the facility details page.
Screenshots of Visual Changes before/after (If There Are Any)
Contribution and Currently Important Rules Acceptance