Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SFI-408] Component rendering order #980

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};
Loading