@mychoice/mychoice-sdk-store 2.1.70 → 2.1.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -6093,6 +6093,8 @@ const useValidationCarDiscount = () => {
6093
6093
  };
6094
6094
  };
6095
6095
 
6096
+ // Module-level flag to prevent duplicate OPTA calls
6097
+ let isOPTACallInProgress = false;
6096
6098
  const useValidationAddress = () => {
6097
6099
  const { dwellingState } = useStoreFormHomeDwelling();
6098
6100
  const { dispatchAppLoaderState } = useStoreAppLoader();
@@ -6127,14 +6129,8 @@ const useValidationAddress = () => {
6127
6129
  });
6128
6130
  if (!errors.length) {
6129
6131
  if (isHomeOwner) {
6130
- try {
6131
- dispatchAppLoaderState({
6132
- type: StoreConfigAppLoaderActionTypes.AppLoaderOpen,
6133
- payload: {
6134
- description: '',
6135
- },
6136
- });
6137
- await getPlaceByAddress(streetAddress, city, postalCode, provinceCode);
6132
+ // Check if OPTA call is already in progress to prevent duplicates
6133
+ if (isOPTACallInProgress) {
6138
6134
  dispatchPostalState({
6139
6135
  type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
6140
6136
  payload: { inValidation: false },
@@ -6144,23 +6140,46 @@ const useValidationAddress = () => {
6144
6140
  payload: { isValid: true },
6145
6141
  });
6146
6142
  formIsValid = true;
6147
- dispatchAppLoaderState({
6148
- type: StoreConfigAppLoaderActionTypes.AppLoaderClose,
6149
- });
6150
6143
  }
6151
- catch (e) {
6152
- dispatchPostalState({
6153
- type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
6154
- payload: { inValidation: false },
6155
- });
6156
- dispatchPostalState({
6157
- type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
6158
- payload: { isValid: true },
6159
- });
6160
- formIsValid = true;
6161
- dispatchAppLoaderState({
6162
- type: StoreConfigAppLoaderActionTypes.AppLoaderClose,
6163
- });
6144
+ else {
6145
+ try {
6146
+ isOPTACallInProgress = true;
6147
+ dispatchAppLoaderState({
6148
+ type: StoreConfigAppLoaderActionTypes.AppLoaderOpen,
6149
+ payload: {
6150
+ description: '',
6151
+ },
6152
+ });
6153
+ await getPlaceByAddress(streetAddress, city, postalCode, provinceCode);
6154
+ isOPTACallInProgress = false;
6155
+ dispatchPostalState({
6156
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
6157
+ payload: { inValidation: false },
6158
+ });
6159
+ dispatchPostalState({
6160
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
6161
+ payload: { isValid: true },
6162
+ });
6163
+ formIsValid = true;
6164
+ dispatchAppLoaderState({
6165
+ type: StoreConfigAppLoaderActionTypes.AppLoaderClose,
6166
+ });
6167
+ }
6168
+ catch (e) {
6169
+ isOPTACallInProgress = false;
6170
+ dispatchPostalState({
6171
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidate,
6172
+ payload: { inValidation: false },
6173
+ });
6174
+ dispatchPostalState({
6175
+ type: StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
6176
+ payload: { isValid: true },
6177
+ });
6178
+ formIsValid = true;
6179
+ dispatchAppLoaderState({
6180
+ type: StoreConfigAppLoaderActionTypes.AppLoaderClose,
6181
+ });
6182
+ }
6164
6183
  }
6165
6184
  }
6166
6185
  else {