Refactoring axo element handling

This commit is contained in:
Pedro Silva 2024-03-12 09:23:42 +00:00
parent 795c1fdcd6
commit a9d2f97a80
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
7 changed files with 109 additions and 77 deletions

View file

@ -1,8 +1,9 @@
import FormFieldGroup from "../Helper/FormFieldGroup";
import FormFieldGroup from "../Components/FormFieldGroup";
class CardView {
constructor(selector, manager) {
constructor(selector, elements, manager) {
this.el = elements;
this.manager = manager;
this.cardFormFields = new FormFieldGroup({
@ -13,21 +14,21 @@ class CardView {
if (!this.manager.hideGatewaySelection) {
return '';
}
return `<p style="margin-top: 40px; text-align: center;"><a href="javascript:void(0)" data-ppcp-axo-show-gateway-selection>Select other payment method</a></p>`;
return `<p style="margin-top: 40px; text-align: center;"><a href="javascript:void(0)" ${this.el.showGatewaySelectionLink.attributes}>Select other payment method</a></p>`;
};
if (data.isEmpty()) {
return `
<div style="margin-bottom: 20px; text-align: center;">
<div>Please fill in your card details.</div>
<h4><a href="javascript:void(0)" data-ppcp-axo-change-card>Edit</a></h4>
<h4><a href="javascript:void(0)" ${this.el.changeCardLink.attributes}>Edit</a></h4>
${selectOtherPaymentMethod()}
</div>
`;
}
return `
<div style="margin-bottom: 20px;">
<h3>Card Details <a href="javascript:void(0)" data-ppcp-axo-change-card>Edit</a></h3>
<h3>Card Details <a href="javascript:void(0)" ${this.el.changeCardLink.attributes}>Edit</a></h3>
<div>${data.value('name')}</div>
<div>${data.value('brand')}</div>
<div>${data.value('lastDigits') ? '************' + data.value('lastDigits'): ''}</div>