Skip to content

Commit 84f7368

Browse files
authored
Frontend/update - button validation + error prevent (#13)
* addition of optional next btn validaiton * prevent rendering errors regarding wrong backend output or api changes * hotfix * cr feedback apply
1 parent a9b9c9d commit 84f7368

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Resources/assets/common/js/geowidget/GeoWidgetPreview.js

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ export class GeoWidgetPreview {
2727
throw new Error('BitBagInPostPlugin - The specified wrapper node could not be found in the DOM');
2828
}
2929

30+
if (!data) {
31+
return;
32+
}
33+
3034
this.wrapper.innerHTML = '';
3135
this.wrapper.insertAdjacentHTML(
3236
'beforeend',

src/Resources/assets/shop/js/inpostPointEvents.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ import triggerCustomEvent from '../../common/js/utilities/triggerCustomEvent';
22
import {ValidateNextBtn} from './nextBtnValidation';
33

44
export class InpostPointEvents {
5-
constructor() {
5+
constructor(config = {}) {
66
const inputs = [...document.querySelectorAll('[value="inpost_point"]')];
77
this.shippingGroups = inputs.map((input) => [...document.querySelectorAll(`[name="${input.name}"]`)]);
8+
this.defaultConfig = {
9+
validateNextBtn: true,
10+
};
11+
this.finalConfig = {
12+
...this.defaultConfig,
13+
...config,
14+
};
815
}
916

1017
init() {
@@ -24,6 +31,11 @@ export class InpostPointEvents {
2431
`inpost.point.${field.value === 'inpost_point' ? 'selected' : 'deselected'}`
2532
);
2633
});
34+
35+
if (!validateNextBtn) {
36+
return;
37+
}
38+
2739
new ValidateNextBtn({node: field}).init();
2840
});
2941
});

0 commit comments

Comments
 (0)