Skip to content

Commit

Permalink
Frontend/update - button validation + error prevent (#13)
Browse files Browse the repository at this point in the history
* addition of optional next btn validaiton

* prevent rendering errors regarding wrong backend output or api changes

* hotfix

* cr feedback apply
  • Loading branch information
Harvel218 authored Mar 30, 2022
1 parent a9b9c9d commit 84f7368
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Resources/assets/common/js/geowidget/GeoWidgetPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class GeoWidgetPreview {
throw new Error('BitBagInPostPlugin - The specified wrapper node could not be found in the DOM');
}

if (!data) {
return;
}

this.wrapper.innerHTML = '';
this.wrapper.insertAdjacentHTML(
'beforeend',
Expand Down
14 changes: 13 additions & 1 deletion src/Resources/assets/shop/js/inpostPointEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import triggerCustomEvent from '../../common/js/utilities/triggerCustomEvent';
import {ValidateNextBtn} from './nextBtnValidation';

export class InpostPointEvents {
constructor() {
constructor(config = {}) {
const inputs = [...document.querySelectorAll('[value="inpost_point"]')];
this.shippingGroups = inputs.map((input) => [...document.querySelectorAll(`[name="${input.name}"]`)]);
this.defaultConfig = {
validateNextBtn: true,
};
this.finalConfig = {
...this.defaultConfig,
...config,
};
}

init() {
Expand All @@ -24,6 +31,11 @@ export class InpostPointEvents {
`inpost.point.${field.value === 'inpost_point' ? 'selected' : 'deselected'}`
);
});

if (!validateNextBtn) {
return;
}

new ValidateNextBtn({node: field}).init();
});
});
Expand Down

0 comments on commit 84f7368

Please sign in to comment.