@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/cjs/index.js CHANGED
@@ -6102,6 +6102,8 @@ const useValidationCarDiscount = () => {
6102
6102
  };
6103
6103
  };
6104
6104
 
6105
+ // Module-level flag to prevent duplicate OPTA calls
6106
+ let isOPTACallInProgress = false;
6105
6107
  const useValidationAddress = () => {
6106
6108
  const { dwellingState } = useStoreFormHomeDwelling();
6107
6109
  const { dispatchAppLoaderState } = useStoreAppLoader();
@@ -6136,14 +6138,8 @@ const useValidationAddress = () => {
6136
6138
  });
6137
6139
  if (!errors.length) {
6138
6140
  if (isHomeOwner) {
6139
- try {
6140
- dispatchAppLoaderState({
6141
- type: exports.StoreConfigAppLoaderActionTypes.AppLoaderOpen,
6142
- payload: {
6143
- description: '',
6144
- },
6145
- });
6146
- await getPlaceByAddress(streetAddress, city, postalCode, provinceCode);
6141
+ // Check if OPTA call is already in progress to prevent duplicates
6142
+ if (isOPTACallInProgress) {
6147
6143
  dispatchPostalState({
6148
6144
  type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidate,
6149
6145
  payload: { inValidation: false },
@@ -6153,23 +6149,46 @@ const useValidationAddress = () => {
6153
6149
  payload: { isValid: true },
6154
6150
  });
6155
6151
  formIsValid = true;
6156
- dispatchAppLoaderState({
6157
- type: exports.StoreConfigAppLoaderActionTypes.AppLoaderClose,
6158
- });
6159
6152
  }
6160
- catch (e) {
6161
- dispatchPostalState({
6162
- type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidate,
6163
- payload: { inValidation: false },
6164
- });
6165
- dispatchPostalState({
6166
- type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
6167
- payload: { isValid: true },
6168
- });
6169
- formIsValid = true;
6170
- dispatchAppLoaderState({
6171
- type: exports.StoreConfigAppLoaderActionTypes.AppLoaderClose,
6172
- });
6153
+ else {
6154
+ try {
6155
+ isOPTACallInProgress = true;
6156
+ dispatchAppLoaderState({
6157
+ type: exports.StoreConfigAppLoaderActionTypes.AppLoaderOpen,
6158
+ payload: {
6159
+ description: '',
6160
+ },
6161
+ });
6162
+ await getPlaceByAddress(streetAddress, city, postalCode, provinceCode);
6163
+ isOPTACallInProgress = false;
6164
+ dispatchPostalState({
6165
+ type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidate,
6166
+ payload: { inValidation: false },
6167
+ });
6168
+ dispatchPostalState({
6169
+ type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
6170
+ payload: { isValid: true },
6171
+ });
6172
+ formIsValid = true;
6173
+ dispatchAppLoaderState({
6174
+ type: exports.StoreConfigAppLoaderActionTypes.AppLoaderClose,
6175
+ });
6176
+ }
6177
+ catch (e) {
6178
+ isOPTACallInProgress = false;
6179
+ dispatchPostalState({
6180
+ type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidate,
6181
+ payload: { inValidation: false },
6182
+ });
6183
+ dispatchPostalState({
6184
+ type: exports.StoreFormHomePostalActionTypes.FormHomePostalValidateSet,
6185
+ payload: { isValid: true },
6186
+ });
6187
+ formIsValid = true;
6188
+ dispatchAppLoaderState({
6189
+ type: exports.StoreConfigAppLoaderActionTypes.AppLoaderClose,
6190
+ });
6191
+ }
6173
6192
  }
6174
6193
  }
6175
6194
  else {