Skip to content

Commit

Permalink
[SFI-408] Component rendering order (#980)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 committed Oct 17, 2023
1 parent cce870b commit e2cfb3f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ Describe the changes proposed in this pull request:
- What existing problem does this pull request solve?
-->

## Tested scenarios
<!-- Description of tested scenarios -->

**Fixed issue**: <!-- #-prefixed issue number -->
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,21 @@ function renderStoredPaymentMethod(imagePath) {
}

function renderStoredPaymentMethods(data, imagePath) {
if (data.storedPaymentMethods) {
const { storedPaymentMethods } = data;
storedPaymentMethods.forEach(renderStoredPaymentMethod(imagePath));
if (data.length) {
data.forEach(renderStoredPaymentMethod(imagePath));
}
}

function renderPaymentMethods(paymentMethods, imagePath, adyenDescriptions) {
const promises = [];
async function renderPaymentMethods(
paymentMethods,
imagePath,
adyenDescriptions,
) {
for (let i = 0; i < paymentMethods.length; i += 1) {
const pm = paymentMethods[i];
promises.push(
renderPaymentMethod(pm, false, imagePath, adyenDescriptions[pm.type]),
);
// eslint-disable-next-line
await renderPaymentMethod(pm, false, imagePath, adyenDescriptions[pm.type]);
}
return Promise.all(promises);
}

function renderPosTerminals(adyenConnectedTerminals) {
Expand Down Expand Up @@ -246,7 +246,15 @@ async function initializeCheckout() {
(pm) => pm.type !== constants.GIFTCARD,
);

renderStoredPaymentMethods(paymentMethodsWithoutGiftCards, session.imagePath);
const storedPaymentMethodsWithoutGiftCards =
store.checkout.paymentMethodsResponse.storedPaymentMethods.filter(
(pm) => pm.type !== constants.GIFTCARD,
);

renderStoredPaymentMethods(
storedPaymentMethodsWithoutGiftCards,
session.imagePath,
);

await renderPaymentMethods(
paymentMethodsWithoutGiftCards,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ module.exports.renderPaymentMethod = async function renderPaymentMethod(
description = null,
rerender = false,
) {
let canRender;
try {
const paymentMethodsUI = document.querySelector('#paymentMethodsList');

Expand Down Expand Up @@ -215,7 +216,11 @@ module.exports.renderPaymentMethod = async function renderPaymentMethod(

handleInput(options);
setValid(options);
canRender = true;
} catch (err) {
// method not available
canRender = false;
}
// eslint-disable-next-line
return canRender;
};

0 comments on commit e2cfb3f

Please sign in to comment.