Skip to content

Commit

Permalink
Improved: method name for removing primary status, and added comments…
Browse files Browse the repository at this point in the history
… for better understanding (#10)
  • Loading branch information
amansinghbais committed Nov 27, 2023
1 parent 68819c3 commit c301ab1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/components/ProductStorePopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default defineComponent({
// Removing store from primary Member group if primary.
if(this.currentProductStore.productStoreId === this.primaryMember.facilityGroupId){
await this.removeProductFromPrimaryMember()
await this.revokePrimaryStatusFromStore()
}
// refetching product stores with updated roles
Expand All @@ -82,16 +82,20 @@ export default defineComponent({
async makePrimary() {
const productStoreId = this.currentProductStore.productStoreId
if(this.primaryMember.facilityGroupId === productStoreId) {
this.removeProductFromPrimaryMember()
this.revokePrimaryStatusFromStore()
popoverController.dismiss()
return;
}
let resp;
let facilityGroupId;
// Fetching the facility group corresponding to the selected product store.
// There should be one facility group where facilityGroupId equals to productStoreId in order
// to manage primary product store of a facility.
facilityGroupId = await this.fetchFacilityGroup(productStoreId)
// Create one facility group corresponding to the selected product store if not exists.
if(!facilityGroupId) {
facilityGroupId = await this.createFacilityGroup(productStoreId)
}
Expand All @@ -106,7 +110,7 @@ export default defineComponent({
if(!hasError(resp)) {
// Remove old primary store
if(this.primaryMember.facilityGroupId) {
await this.removeProductFromPrimaryMember()
await this.revokePrimaryStatusFromStore()
}
} else {
throw resp.data
Expand Down Expand Up @@ -162,7 +166,7 @@ export default defineComponent({
return facilityGroupId
},
async removeProductFromPrimaryMember() {
async revokePrimaryStatusFromStore() {
let resp;
try {
resp = await FacilityService.updateFacilityToGroup({
Expand Down
4 changes: 2 additions & 2 deletions src/views/FacilityDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export default defineComponent({
} else {
productStoresToRemove.map((store: any) => {
if(store.productStoreId === this.primaryMember.facilityGroupId) {
this.removeProductFromPrimaryMember()
this.revokePrimaryStatusFromStore()
}
})
showToast(translate("Product stores updated successfully."))
Expand Down Expand Up @@ -701,7 +701,7 @@ export default defineComponent({
logger.error('Failed to update fulfillment setting', err)
}
},
async removeProductFromPrimaryMember() {
async revokePrimaryStatusFromStore() {
let resp;
try {
resp = await FacilityService.updateFacilityToGroup({

Check warning on line 707 in src/views/FacilityDetails.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (16.x)

'resp' is assigned a value but never used
Expand Down

0 comments on commit c301ab1

Please sign in to comment.