Skip to content

Commit

Permalink
Improved: address modal to have a loader before populating data and a…
Browse files Browse the repository at this point in the history
…dded a null check on geoCode(#73)
  • Loading branch information
ymaheshwari1 committed Jun 18, 2024
1 parent bf433cb commit 6b62bbb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"Failed to cancel the order": "Failed to cancel the order",
"Failed to update the pickup store": "Failed to update the pickup store",
"Failed to update the shipping addess": "Failed to update the shipping addess",
"Fetching address": "Fetching address",
"Last name": "Last name",
"Login": "Login",
"Logout": "Logout",
Expand Down
25 changes: 22 additions & 3 deletions src/views/AddressModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ import {
IonSelectOption,
IonTitle,
IonToolbar,
modalController
modalController,
loadingController
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { closeOutline } from 'ionicons/icons';
Expand Down Expand Up @@ -90,13 +91,16 @@ export default defineComponent({
countryGeoId: ""
} as any,
contactMechId: '',
states: [] as any
states: [] as any,
loader: null as any
};
},
props: ["shipGroup", "token"],
async mounted() {
this.presentLoader()
await this.getAssociatedStates()
if (this.shipGroup.shipmentMethodTypeId != 'STOREPICKUP') this.prepareAddress();
this.dismissLoader()
},
methods: {
async updateAddress() {
Expand All @@ -106,7 +110,9 @@ export default defineComponent({
})
if (hasEmptyValues) return showToast(translate("Please fill all the fields"))
const state = this.states.find((state: any) => state.geoId === this.address.stateProvinceGeoId);
this.address.stateCode = state.geoCode;
// In some cases, we get a stateProvinceGeoId that does not exist in data, thus state is not displayed on the UI but originally the field has information thus toast of empty field is not displayed
// thus added a check that if the geoCode is not found in the states fetched from the server, do not stop the address update process and pass the same state that was previously in the address.
this.address.stateCode = state?.geoCode || this.address.stateProvinceGeoId;
this.close(this.address);
},
prepareAddress() {
Expand Down Expand Up @@ -143,6 +149,19 @@ export default defineComponent({
close(address?: any) {
modalController.dismiss({ dismissed: true }, address);
},
async presentLoader() {
this.loader = await loadingController
.create({
message: this.$t("Fetching address")
});
await this.loader.present();
},
dismissLoader() {
if (this.loader) {
this.loader.dismiss();
this.loader = null;
}
},
},
setup() {
const router = useRouter();
Expand Down

0 comments on commit 6b62bbb

Please sign in to comment.