@internetarchive/donation-monthly-portal 0.0.0-payment-method-alpha2 → 0.0.0-paypal-payment-method-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/edit-plan-form.d.ts +5 -13
- package/dist/src/edit-plan-form.js +32 -44
- package/dist/src/edit-plan-form.js.map +1 -1
- package/dist/src/form-sections/amount.js +24 -9
- package/dist/src/form-sections/amount.js.map +1 -1
- package/dist/src/form-sections/cancel.d.ts +1 -1
- package/dist/src/form-sections/cancel.js +20 -17
- package/dist/src/form-sections/cancel.js.map +1 -1
- package/dist/src/form-sections/date.d.ts +2 -1
- package/dist/src/form-sections/date.js +2 -0
- package/dist/src/form-sections/date.js.map +1 -1
- package/dist/src/form-sections/parts/braintree-manager.d.ts +7 -4
- package/dist/src/form-sections/parts/braintree-manager.js +106 -48
- package/dist/src/form-sections/parts/braintree-manager.js.map +1 -1
- package/dist/src/form-sections/payment-method.d.ts +4 -12
- package/dist/src/form-sections/payment-method.js +120 -98
- package/dist/src/form-sections/payment-method.js.map +1 -1
- package/dist/src/models/payment-method-request.d.ts +13 -2
- package/dist/src/models/payment-method-request.js.map +1 -1
- package/dist/src/models/plan.d.ts +6 -5
- package/dist/src/models/plan.js +47 -50
- package/dist/src/models/plan.js.map +1 -1
- package/dist/src/models/receipt.d.ts +3 -5
- package/dist/src/models/receipt.js +3 -17
- package/dist/src/models/receipt.js.map +1 -1
- package/dist/src/monthly-giving-circle.d.ts +15 -5
- package/dist/src/monthly-giving-circle.js +27 -15
- package/dist/src/monthly-giving-circle.js.map +1 -1
- package/dist/src/plans.js +8 -10
- package/dist/src/plans.js.map +1 -1
- package/dist/src/presentational/donation-section-info.d.ts +1 -0
- package/dist/src/presentational/donation-section-info.js +9 -2
- package/dist/src/presentational/donation-section-info.js.map +1 -1
- package/dist/src/presentational/mgc-button.js +6 -1
- package/dist/src/presentational/mgc-button.js.map +1 -1
- package/dist/src/presentational/mgc-title.js.map +1 -1
- package/dist/src/presentational/mgc-update-status.js.map +1 -1
- package/dist/src/receipts.d.ts +2 -2
- package/dist/src/receipts.js +9 -11
- package/dist/src/receipts.js.map +1 -1
- package/dist/src/utils/currency-format.d.ts +2 -0
- package/dist/src/utils/currency-format.js +20 -0
- package/dist/src/utils/currency-format.js.map +1 -0
- package/dist/src/welcome-message.js.map +1 -1
- package/dist/test/cancel-plan-flow.test.d.ts +1 -0
- package/dist/test/cancel-plan-flow.test.js +126 -0
- package/dist/test/cancel-plan-flow.test.js.map +1 -0
- package/dist/test/edit-plan-flow-error-callbacks.test.d.ts +1 -0
- package/dist/test/edit-plan-flow-error-callbacks.test.js +122 -0
- package/dist/test/edit-plan-flow-error-callbacks.test.js.map +1 -0
- package/dist/test/edit-plan-flow-payment-method.test.d.ts +1 -0
- package/dist/test/edit-plan-flow-payment-method.test.js +192 -0
- package/dist/test/edit-plan-flow-payment-method.test.js.map +1 -0
- package/dist/test/edit-plan-flow.test.d.ts +1 -0
- package/dist/test/edit-plan-flow.test.js +215 -0
- package/dist/test/edit-plan-flow.test.js.map +1 -0
- package/dist/test/edit-plan-form.test.js.map +1 -1
- package/dist/test/form-sections/amount.test.js +41 -0
- package/dist/test/form-sections/amount.test.js.map +1 -1
- package/dist/test/form-sections/date.test.js +1 -2
- package/dist/test/form-sections/date.test.js.map +1 -1
- package/dist/test/helpers/edit-plan-helpers.d.ts +5 -0
- package/dist/test/helpers/edit-plan-helpers.js +45 -0
- package/dist/test/helpers/edit-plan-helpers.js.map +1 -0
- package/dist/test/models/payment-method-request.test.d.ts +1 -0
- package/dist/test/models/payment-method-request.test.js +62 -0
- package/dist/test/models/payment-method-request.test.js.map +1 -0
- package/dist/test/models/plan.test.d.ts +1 -0
- package/dist/test/models/plan.test.js +488 -0
- package/dist/test/models/plan.test.js.map +1 -0
- package/dist/test/models/receipt.test.d.ts +1 -0
- package/dist/test/models/receipt.test.js +79 -0
- package/dist/test/models/receipt.test.js.map +1 -0
- package/dist/test/monthly-giving-circle.test.js.map +1 -1
- package/dist/test/receipt-email-request-flow.test.js +4 -0
- package/dist/test/receipt-email-request-flow.test.js.map +1 -1
- package/dist/test/state-persistence-across-views.test.d.ts +1 -0
- package/dist/test/state-persistence-across-views.test.js +67 -0
- package/dist/test/state-persistence-across-views.test.js.map +1 -0
- package/dist/test/utils/currency-format.test.d.ts +1 -0
- package/dist/test/utils/currency-format.test.js +41 -0
- package/dist/test/utils/currency-format.test.js.map +1 -0
- package/dist/test/welcome-message.test.d.ts +1 -0
- package/dist/test/welcome-message.test.js +90 -0
- package/dist/test/welcome-message.test.js.map +1 -0
- package/package.json +22 -15
- package/src/edit-plan-form.ts +40 -69
- package/src/form-sections/amount.ts +28 -12
- package/src/form-sections/cancel.ts +28 -25
- package/src/form-sections/date.ts +3 -1
- package/src/form-sections/parts/braintree-manager.ts +204 -90
- package/src/form-sections/payment-method.ts +163 -144
- package/src/models/payment-method-request.ts +16 -5
- package/src/models/plan.ts +51 -61
- package/src/models/receipt.ts +8 -23
- package/src/monthly-giving-circle.ts +49 -18
- package/src/plans.ts +10 -11
- package/src/presentational/donation-section-info.ts +10 -2
- package/src/presentational/mgc-button.ts +7 -2
- package/src/receipts.ts +14 -16
- package/src/utils/currency-format.ts +23 -0
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@@ -1,144 +1,17 @@
|
|
2
|
-
 [ [](https://codecov.io/github/internetarchive/iaux-monthly-giving-circle)
|
|
3
3
|
|
|
4
4
|
# \<iaux-monthly-giving-circle>
|
|
5
5
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { MonthlyGivingCircle } from './src/monthly-giving-circle';\nexport type { APlanUpdate } from './src/monthly-giving-circle';\nexport { Receipt } from './src/models/receipt';\nexport type { AReceipt } from './src/models/receipt';\nexport { MonthlyPlan } from './src/models/plan';\nexport type { Plan, BtData } from './src/models/plan';\nexport type { PaymentMethodRequest } from './src/models/payment-method-request'
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { MonthlyGivingCircle } from './src/monthly-giving-circle';\nexport type { APlanUpdate } from './src/monthly-giving-circle';\nexport { Receipt } from './src/models/receipt';\nexport type { AReceipt } from './src/models/receipt';\nexport { MonthlyPlan } from './src/models/plan';\nexport type { Plan, BtData } from './src/models/plan';\nexport type { PaymentMethodRequest } from './src/models/payment-method-request';\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LitElement
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
2
|
import '@internetarchive/donation-form/dist/src/form-elements/badged-input';
|
|
3
|
-
import {
|
|
3
|
+
import type { PaymentConfig } from './form-sections/parts/braintree-manager';
|
|
4
4
|
import type { MonthlyPlan } from './models/plan';
|
|
5
5
|
import './form-sections/amount';
|
|
6
6
|
import './form-sections/date';
|
|
@@ -9,22 +9,14 @@ import './form-sections/payment-method';
|
|
|
9
9
|
export declare class IauxEditPlanForm extends LitElement {
|
|
10
10
|
plan?: MonthlyPlan;
|
|
11
11
|
patronEmail: string;
|
|
12
|
+
canEditPaymentMethod: boolean;
|
|
12
13
|
updateAmountHandler?: (plan: MonthlyPlan, amountUpdates: {
|
|
13
14
|
amount: number;
|
|
14
15
|
baseAmount: number;
|
|
15
16
|
coverFees: boolean;
|
|
16
17
|
feeCovered: number;
|
|
17
18
|
}) => void;
|
|
18
|
-
paymentConfig:
|
|
19
|
-
referrer: string;
|
|
20
|
-
origin: string;
|
|
21
|
-
braintreeAuthToken: string;
|
|
22
|
-
venmoProfileId: string;
|
|
23
|
-
googlePayMerchantId: string;
|
|
24
|
-
environment: string;
|
|
25
|
-
paymentClients: PaymentClientsInterface | undefined;
|
|
26
|
-
endpointManager: object;
|
|
27
|
-
};
|
|
19
|
+
paymentConfig: PaymentConfig;
|
|
28
20
|
braintreeNumberInput: HTMLDivElement;
|
|
29
21
|
braintreeExpirationDateInput: HTMLDivElement;
|
|
30
22
|
braintreeCVVInput: HTMLDivElement;
|
|
@@ -33,6 +25,6 @@ export declare class IauxEditPlanForm extends LitElement {
|
|
|
33
25
|
paymentMethodUpdates(status: 'success' | 'fail'): void;
|
|
34
26
|
amountUpdates(status: 'success' | 'fail'): void;
|
|
35
27
|
dateUpdates(status: 'success' | 'fail'): void;
|
|
36
|
-
render(): TemplateResult<1>;
|
|
28
|
+
render(): import("lit").TemplateResult<1>;
|
|
37
29
|
mailToText(): string;
|
|
38
30
|
}
|
|
@@ -2,13 +2,7 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { LitElement, html } from 'lit';
|
|
3
3
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
4
|
import '@internetarchive/donation-form/dist/src/form-elements/badged-input';
|
|
5
|
-
import {
|
|
6
|
-
// import { HostedFieldContainer, HostedFieldContainerInterface } from '@internetarchive/donation-form/dist/src/braintree-manager/payment-providers/credit-card/hosted-field-container';
|
|
7
|
-
import { HostingEnvironment } from '@internetarchive/donation-form/dist/src/braintree-manager/braintree-interfaces.js';
|
|
8
|
-
import { PaymentClients } from '@internetarchive/donation-form/dist/src/braintree-manager/payment-clients.js';
|
|
9
|
-
import '@internetarchive/icon-credit-card/index.js';
|
|
10
|
-
import '@internetarchive/icon-calendar/index.js';
|
|
11
|
-
import '@internetarchive/icon-lock/index.js';
|
|
5
|
+
import { HostingEnvironment } from '@internetarchive/donation-form';
|
|
12
6
|
import './form-sections/amount';
|
|
13
7
|
import './form-sections/date';
|
|
14
8
|
import './form-sections/cancel';
|
|
@@ -17,28 +11,16 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
17
11
|
constructor() {
|
|
18
12
|
super(...arguments);
|
|
19
13
|
this.patronEmail = '';
|
|
14
|
+
this.canEditPaymentMethod = false;
|
|
20
15
|
this.paymentConfig = {
|
|
21
16
|
referrer: '',
|
|
22
17
|
origin: '',
|
|
23
|
-
braintreeAuthToken: '
|
|
24
|
-
venmoProfileId: '
|
|
18
|
+
braintreeAuthToken: '',
|
|
19
|
+
venmoProfileId: '',
|
|
25
20
|
googlePayMerchantId: '',
|
|
26
|
-
environment:
|
|
27
|
-
paymentClients:
|
|
28
|
-
endpointManager:
|
|
29
|
-
// eslint-disable-next-line arrow-body-style
|
|
30
|
-
submitData: async (request) => {
|
|
31
|
-
// Implement your submit logic here
|
|
32
|
-
// Return a DonationResponse object with at least a 'value' property
|
|
33
|
-
return Promise.resolve({
|
|
34
|
-
value: {},
|
|
35
|
-
success: true,
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
donationSuccessful: (response) =>
|
|
39
|
-
// Implement your donation success logic here
|
|
40
|
-
true
|
|
41
|
-
},
|
|
21
|
+
environment: HostingEnvironment.Development,
|
|
22
|
+
paymentClients: undefined,
|
|
23
|
+
endpointManager: undefined,
|
|
42
24
|
};
|
|
43
25
|
}
|
|
44
26
|
createRenderRoot() {
|
|
@@ -58,7 +40,6 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
58
40
|
}
|
|
59
41
|
render() {
|
|
60
42
|
return html `
|
|
61
|
-
|
|
62
43
|
<section class="mgc-edit-plan">
|
|
63
44
|
<ia-mgc-edit-plan-amount
|
|
64
45
|
.plan=${this.plan}
|
|
@@ -75,24 +56,28 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
75
56
|
}
|
|
76
57
|
}}
|
|
77
58
|
></ia-mgc-edit-plan-amount>
|
|
59
|
+
${this.canEditPaymentMethod
|
|
60
|
+
? html `
|
|
61
|
+
<hr />
|
|
62
|
+
<ia-mgc-edit-payment-method
|
|
63
|
+
.plan=${this.plan}
|
|
64
|
+
.patronEmail=${this.patronEmail}
|
|
65
|
+
.paymentConfig=${this.paymentConfig}
|
|
66
|
+
@UpdatePaymentMethod=${(e) => {
|
|
67
|
+
const { newPaymentMethodRequest } = e.detail;
|
|
68
|
+
if (this.plan) {
|
|
69
|
+
this.dispatchEvent(new CustomEvent('UpdatePaymentMethod', {
|
|
70
|
+
detail: { plan: this.plan, newPaymentMethodRequest },
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
</ia-mgc-edit-payment-method>
|
|
76
|
+
`
|
|
77
|
+
: ''}
|
|
78
78
|
<hr />
|
|
79
|
-
<ia-mgc-edit-
|
|
80
|
-
|
|
81
|
-
.patronEmail=${this.patronEmail}
|
|
82
|
-
.paymentConfig=${this.paymentConfig}
|
|
83
|
-
@UpdatePaymentMethod=${(e) => {
|
|
84
|
-
const { newPaymentMethodRequest } = e.detail;
|
|
85
|
-
if (this.plan) {
|
|
86
|
-
this.dispatchEvent(new CustomEvent('UpdatePaymentMethod', {
|
|
87
|
-
detail: { plan: this.plan, newPaymentMethodRequest },
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
</ia-mgc-edit-payment-method>
|
|
93
|
-
<hr />
|
|
94
|
-
<ia-mgc-edit-date
|
|
95
|
-
@updateDate=${(e) => {
|
|
79
|
+
<ia-mgc-edit-date
|
|
80
|
+
@updateDate=${(e) => {
|
|
96
81
|
const { newDate } = e.detail;
|
|
97
82
|
if (this.plan) {
|
|
98
83
|
this.dispatchEvent(new CustomEvent('updateDate', {
|
|
@@ -112,7 +97,7 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
112
97
|
<hr />
|
|
113
98
|
<p class="email-edit-plan">
|
|
114
99
|
Need to update your plan further? Please email us at
|
|
115
|
-
<a href=${this.mailToText}>donations@archive.org</a>.
|
|
100
|
+
<a href=${this.mailToText()}>donations@archive.org</a>.
|
|
116
101
|
</p>
|
|
117
102
|
</section>
|
|
118
103
|
`;
|
|
@@ -127,6 +112,9 @@ __decorate([
|
|
|
127
112
|
__decorate([
|
|
128
113
|
property({ type: String })
|
|
129
114
|
], IauxEditPlanForm.prototype, "patronEmail", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: Boolean })
|
|
117
|
+
], IauxEditPlanForm.prototype, "canEditPaymentMethod", void 0);
|
|
130
118
|
__decorate([
|
|
131
119
|
property({ type: Object })
|
|
132
120
|
], IauxEditPlanForm.prototype, "updateAmountHandler", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-plan-form.js","sourceRoot":"","sources":["../../src/edit-plan-form.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"edit-plan-form.js","sourceRoot":"","sources":["../../src/edit-plan-form.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,oEAAoE,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,wBAAwB,CAAC;AAChC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wBAAwB,CAAC;AAChC,OAAO,gCAAgC,CAAC;AAMjC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QAGuB,gBAAW,GAAW,EAAE,CAAC;QAExB,yBAAoB,GAAY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,OAAO,EAAE,CAAC;8DAAuC;AAEvC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAQjB;AAEkB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDASzB;AAE8B;IAA/B,KAAK,CAAC,uBAAuB,CAAC;8DAAuC;AAEtC;IAA/B,KAAK,CAAC,uBAAuB,CAAC;sEAA+C;AAErD;IAAxB,KAAK,CAAC,gBAAgB,CAAC;2DAAoC;AAEzB;IAAlC,KAAK,CAAC,0BAA0B,CAAC;+DAAwC;AAlC/D,gBAAgB;IAD5B,aAAa,CAAC,kBAAkB,CAAC;GACrB,gBAAgB,CAkI5B","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\n\nimport '@internetarchive/donation-form/dist/src/form-elements/badged-input';\n\nimport { HostingEnvironment } from '@internetarchive/donation-form';\nimport type { PaymentConfig } from './form-sections/parts/braintree-manager';\nimport type { MonthlyPlan } from './models/plan';\nimport './form-sections/amount';\nimport './form-sections/date';\nimport './form-sections/cancel';\nimport './form-sections/payment-method';\nimport type { MGCEditPlanAmount } from './form-sections/amount';\nimport type { MGCEditPlanDate } from './form-sections/date';\nimport type { MGCEditPaymentMethod } from './form-sections/payment-method';\n\n@customElement('ia-mgc-edit-plan')\nexport class IauxEditPlanForm extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n @property({ type: String }) patronEmail: string = '';\n\n @property({ type: Boolean }) canEditPaymentMethod: boolean = false;\n\n @property({ type: Object }) updateAmountHandler?: (\n plan: MonthlyPlan,\n amountUpdates: {\n amount: number;\n baseAmount: number;\n coverFees: boolean;\n feeCovered: number;\n },\n ) => void;\n\n @property({ type: Object }) paymentConfig: PaymentConfig = {\n referrer: '',\n origin: '',\n braintreeAuthToken: '',\n venmoProfileId: '',\n googlePayMerchantId: '',\n environment: HostingEnvironment.Development,\n paymentClients: undefined,\n endpointManager: undefined,\n };\n\n @query('#braintree-creditcard') braintreeNumberInput!: HTMLDivElement;\n\n @query('#braintree-expiration') braintreeExpirationDateInput!: HTMLDivElement;\n\n @query('#braintree-cvv') braintreeCVVInput!: HTMLDivElement;\n\n @query('#braintree-error-message') braintreeErrorMessage!: HTMLDivElement;\n\n createRenderRoot() {\n return this;\n }\n\n paymentMethodUpdates(status: 'success' | 'fail') {\n const paymentMethodForm = this.querySelector(\n 'ia-mgc-edit-payment-method',\n ) as MGCEditPaymentMethod;\n paymentMethodForm!.paymentMethodUpdated(status);\n }\n\n amountUpdates(status: 'success' | 'fail') {\n const amountForm = this.querySelector(\n 'ia-mgc-edit-plan-amount',\n ) as MGCEditPlanAmount;\n amountForm!.amountUpdated(status);\n }\n\n dateUpdates(status: 'success' | 'fail') {\n const dateForm = this.querySelector('ia-mgc-edit-date') as MGCEditPlanDate;\n dateForm!.dateUpdated(status);\n }\n\n render() {\n return html`\n <section class=\"mgc-edit-plan\">\n <ia-mgc-edit-plan-amount\n .plan=${this.plan}\n @updateAmount=${(e: CustomEvent) => {\n const { amount, baseAmount, coverFees, feeCovered } = e.detail;\n if (this.plan) {\n this.updateAmountHandler?.(this.plan, {\n amount,\n baseAmount,\n coverFees,\n feeCovered,\n });\n }\n }}\n ></ia-mgc-edit-plan-amount>\n ${this.canEditPaymentMethod\n ? html`\n <hr />\n <ia-mgc-edit-payment-method\n .plan=${this.plan}\n .patronEmail=${this.patronEmail}\n .paymentConfig=${this.paymentConfig}\n @UpdatePaymentMethod=${(e: CustomEvent) => {\n const { newPaymentMethodRequest } = e.detail;\n if (this.plan) {\n this.dispatchEvent(\n new CustomEvent('UpdatePaymentMethod', {\n detail: { plan: this.plan, newPaymentMethodRequest },\n }),\n );\n }\n }}\n >\n </ia-mgc-edit-payment-method>\n `\n : ''}\n <hr />\n <ia-mgc-edit-date\n @updateDate=${(e: CustomEvent) => {\n const { newDate } = e.detail;\n if (this.plan) {\n this.dispatchEvent(\n new CustomEvent('updateDate', {\n detail: { plan: this.plan, newDate },\n }),\n );\n }\n }}\n .plan=${this.plan}\n ></ia-mgc-edit-date>\n <hr />\n <ia-mgc-cancel-plan\n .plan=${this.plan}\n @cancelPlan=${() => {\n this.dispatchEvent(new Event('cancelPlan'));\n }}\n ></ia-mgc-cancel-plan>\n <hr />\n <p class=\"email-edit-plan\">\n Need to update your plan further? Please email us at\n <a href=${this.mailToText()}>donations@archive.org</a>.\n </p>\n </section>\n `;\n }\n\n mailToText(): string {\n return `mailto:donations@archive.org?subject=I'd like to update my monthly donation`;\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { LitElement, html, nothing, css, } from 'lit';
|
|
|
3
3
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
4
4
|
import '@internetarchive/donation-form-section';
|
|
5
5
|
import { DonationPaymentInfo, DonationType, } from '@internetarchive/donation-form-data-models';
|
|
6
|
+
import { formatCurrency, currencyToSymbol } from '../utils/currency-format';
|
|
6
7
|
import '../presentational/donation-section-info';
|
|
7
8
|
import '../presentational/mgc-button';
|
|
8
9
|
import '../presentational/mgc-update-status';
|
|
@@ -31,7 +32,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
render() {
|
|
34
|
-
var _a;
|
|
35
|
+
var _a, _b;
|
|
35
36
|
return html `
|
|
36
37
|
<section>
|
|
37
38
|
<donation-form-section badgemode="hidebadge" headline="Amount">
|
|
@@ -41,7 +42,9 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
41
42
|
this.currentlyEditing = true;
|
|
42
43
|
this.clearStatusMessaging();
|
|
43
44
|
}}
|
|
44
|
-
><span
|
|
45
|
+
><span
|
|
46
|
+
>${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.currency} ${(_b = this.plan) === null || _b === void 0 ? void 0 : _b.amountFormatted}</span
|
|
47
|
+
>
|
|
45
48
|
</ia-mgc-form-section-info>`
|
|
46
49
|
: nothing}
|
|
47
50
|
${this.currentlyEditing ? this.editAmountForm : nothing}
|
|
@@ -54,7 +57,9 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
54
57
|
this.clearInputField();
|
|
55
58
|
this.updateStatus = status;
|
|
56
59
|
this.updateMessage =
|
|
57
|
-
status === 'success'
|
|
60
|
+
status === 'success'
|
|
61
|
+
? 'Amount updated'
|
|
62
|
+
: 'Failed to update date, please try again';
|
|
58
63
|
if (status === 'success') {
|
|
59
64
|
this.closeForm();
|
|
60
65
|
await this.updateComplete;
|
|
@@ -182,20 +187,26 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
182
187
|
return DonationPaymentInfo.calculateTotal(this.newAmount, this.coverFees);
|
|
183
188
|
}
|
|
184
189
|
get coveredFeesText() {
|
|
185
|
-
|
|
186
|
-
|
|
190
|
+
if (!this.newAmount) {
|
|
191
|
+
return "I'll generously cover the fees.";
|
|
192
|
+
}
|
|
193
|
+
const fee = DonationPaymentInfo.calculateFeeAmount(this.newAmount);
|
|
194
|
+
return `I'll generously add ${formatCurrency(fee)} to cover fees.`;
|
|
187
195
|
}
|
|
188
196
|
get editAmountForm() {
|
|
189
|
-
var _a;
|
|
197
|
+
var _a, _b, _c, _d, _e;
|
|
190
198
|
return html `
|
|
191
199
|
<section>
|
|
192
200
|
<form
|
|
193
201
|
id="edit-plan-amount"
|
|
194
202
|
@submit=${(e) => this.handleSubmit(e)}
|
|
195
203
|
>
|
|
196
|
-
<p>
|
|
204
|
+
<p>
|
|
205
|
+
Current donation amount: ${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.currency}
|
|
206
|
+
${(_b = this.plan) === null || _b === void 0 ? void 0 : _b.amountFormatted}
|
|
207
|
+
</p>
|
|
197
208
|
<div>
|
|
198
|
-
$
|
|
209
|
+
${currencyToSymbol[(_d = (_c = this.plan) === null || _c === void 0 ? void 0 : _c.currency) !== null && _d !== void 0 ? _d : 'USD']}
|
|
199
210
|
<input
|
|
200
211
|
min="1"
|
|
201
212
|
max="9999"
|
|
@@ -227,7 +238,10 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
227
238
|
/>
|
|
228
239
|
<label for="cover-fees">${this.coveredFeesText}</label>
|
|
229
240
|
</div>
|
|
230
|
-
<p>
|
|
241
|
+
<p>
|
|
242
|
+
Total: ${(_e = this.plan) === null || _e === void 0 ? void 0 : _e.currency}
|
|
243
|
+
${formatCurrency(this.totalAmountWithFees())}
|
|
244
|
+
</p>
|
|
231
245
|
<div class="cta-container">
|
|
232
246
|
<ia-mgc-button
|
|
233
247
|
class="ia-button secondary"
|
|
@@ -242,6 +256,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
242
256
|
id="update-amount"
|
|
243
257
|
class="ia-button primary"
|
|
244
258
|
type="submit"
|
|
259
|
+
?isDisabled=${!this.newAmount}
|
|
245
260
|
.clickHandler=${(e, iaButton) => this.handleSubmit(e, iaButton)}
|
|
246
261
|
>
|
|
247
262
|
Update
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/form-sections/amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,OAAO,EACP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,wCAAwC,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,YAAY,GACb,MAAM,4CAA4C,CAAC;AAGpD,OAAO,yCAAyC,CAAC;AACjD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,qCAAqC,CAAC;AAG7C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,UAAU;IAAjD;;QAM8B,cAAS,GAAW,CAAC,CAAC;QAEN,qBAAgB,GAAY,KAAK,CAAC;QAEjD,cAAS,GAAY,KAAK,CAAC;QA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EAAE,CAAC;wDAA4B;AAE3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA2B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA4C;AAExD;IAAd,KAAK,CAAC,MAAM,CAAC;+CAAwB;AAlB3B,iBAAiB;IAD7B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,iBAAiB,CA4U7B;SA5UY,iBAAiB","sourcesContent":["import {\n LitElement,\n html,\n PropertyValues,\n nothing,\n css,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport '@internetarchive/donation-form-section';\nimport {\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\n\nimport type { MonthlyPlan } from '../models/plan';\nimport '../presentational/donation-section-info';\nimport '../presentational/mgc-button';\nimport type { MGCButton } from '../presentational/mgc-button';\nimport '../presentational/mgc-update-status';\n\n@customElement('ia-mgc-edit-plan-amount')\nexport class MGCEditPlanAmount extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n // captures the changes made to the amount && calculates the total amount with fees\n @property({ type: Object }) donationPaymentInfo?: DonationPaymentInfo;\n\n @property({ type: Number }) newAmount: number = 0;\n\n @property({ type: Boolean, reflect: true }) currentlyEditing: boolean = false;\n\n @property({ type: Boolean }) coverFees: boolean = false;\n\n @property({ type: String }) updateMessage: string = '';\n\n @property({ type: String }) errorMessage: string = '';\n\n @property({ type: String }) updateStatus: 'success' | 'fail' | '' = '';\n\n @query('form') form!: HTMLFormElement;\n\n updated(changed: PropertyValues) {\n if (changed.has('plan') && this.plan) {\n this.captureAmountChanges();\n }\n if (changed.has('coverFees')) {\n this.captureAmountChanges();\n }\n if (changed.has('currentlyEditing') && this.currentlyEditing) {\n this.form.focus();\n }\n\n if (changed.has('donationPaymentInfo') && !this.donationPaymentInfo) {\n this.captureAmountChanges();\n }\n }\n\n protected render() {\n return html`\n <section>\n <donation-form-section badgemode=\"hidebadge\" headline=\"Amount\">\n ${!this.currentlyEditing\n ? html`<ia-mgc-form-section-info\n @editingRequested=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n ><span>USD $${this.plan?.amount}</span>\n </ia-mgc-form-section-info>`\n : nothing}\n ${this.currentlyEditing ? this.editAmountForm : nothing}\n </donation-form-section>\n </section>\n `;\n }\n\n /* External Function that is called by consumer to tell the form there has been data update */\n async amountUpdated(status: 'success' | 'fail') {\n this.clearInputField();\n\n this.updateStatus = status;\n this.updateMessage =\n status === 'success' ? 'Amount updated' : 'Failed to update date, please try again';\n\n if (status === 'success') {\n this.closeForm();\n await this.updateComplete;\n\n this.updateStatus = status;\n this.updateMessage = 'Amount updated';\n\n return;\n }\n\n (\n this.form.querySelector('ia-mgc-button#update-amount') as MGCButton\n ).isDisabled = false;\n\n this.captureAmountChanges();\n\n await this.updateComplete;\n }\n\n /* Dispatches amount change request */\n requestAmountUpdate(e: Event): void {\n e.preventDefault();\n\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n this.newAmount = Number(input.value);\n\n this.captureAmountChanges(this.newAmount);\n\n console.log('<plan-amount> - update amount', {\n newValue: this.newAmount,\n oldValue: this.plan?.plan.amount,\n display: this.donationPaymentInfo?.amount,\n });\n const newAmount = Number(\n DonationPaymentInfo.calculateTotal(\n Number(this.donationPaymentInfo?.amount),\n this.coverFees\n )\n );\n this.dispatchEvent(\n new CustomEvent('updateAmount', {\n detail: {\n plan: this.plan,\n amount: newAmount,\n baseAmount: this.donationPaymentInfo?.amount,\n coverFees: this.coverFees,\n feeCovered: this.donationPaymentInfo?.feeAmountCovered,\n },\n })\n );\n }\n\n /* captures form changes */\n captureAmountChanges(newAmount?: number) {\n if (!this.donationPaymentInfo && this.plan) {\n this.donationPaymentInfo = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: 0,\n coverFees: true,\n });\n return;\n }\n\n let newPlan;\n if (newAmount) {\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: newAmount,\n coverFees: true,\n });\n } else {\n const amount = this.donationPaymentInfo\n ? this.donationPaymentInfo.amount\n : this.plan!.amount;\n\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount,\n coverFees: true,\n });\n }\n\n this.donationPaymentInfo = newPlan;\n }\n\n closeForm() {\n this.clearInputField();\n this.clearStatusMessaging();\n this.currentlyEditing = false;\n this.coverFees = false;\n this.errorMessage = '';\n }\n\n clearInputField() {\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n input.value = '';\n this.newAmount = 0;\n this.donationPaymentInfo = undefined;\n }\n\n handleSubmit(e: Event, iaButton?: MGCButton) {\n e.preventDefault();\n this.clearStatusMessaging();\n\n const button =\n iaButton ?? (this.form.querySelector('#update-amount') as MGCButton);\n if (button) this.updateButtonState(button);\n\n if (!this.newAmount) {\n this.errorMessage = 'Please enter a new amount';\n if (button) button.isDisabled = false;\n return;\n }\n\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n const requestedAmount = Number(input.value) ?? 0;\n const amountTooLow = requestedAmount < 1;\n const amountTooHigh = requestedAmount >= 9999;\n\n if (amountTooLow) {\n this.errorMessage = 'Please enter a valid amount';\n }\n\n if (amountTooHigh) {\n this.errorMessage =\n 'Amount must be less than $9,999. Would you like to donate more? Please contact us at donations@archive.org';\n }\n\n if (amountTooHigh || amountTooLow) {\n if (button) this.updateButtonState(button);\n return;\n }\n\n this.requestAmountUpdate(e);\n }\n\n private async updateButtonState(iaButton: MGCButton) {\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton?.updateComplete;\n }\n\n async clearStatusMessaging() {\n this.errorMessage = '';\n this.updateMessage = '';\n this.updateStatus = '';\n await this.updateComplete;\n }\n\n /* DISPLAY */\n totalAmountWithFees(): number {\n if (this.newAmount === 0) {\n return 0;\n }\n\n return DonationPaymentInfo.calculateTotal(this.newAmount, this.coverFees);\n }\n\n get coveredFeesText() {\n return `I'll generously add $${this.donationPaymentInfo?.feeAmountCovered} to cover fees.`;\n }\n\n get editAmountForm(): TemplateResult {\n return html`\n <section>\n <form\n id=\"edit-plan-amount\"\n @submit=${(e: Event) => this.handleSubmit(e)}\n >\n <p>Current donation amount: $${this.plan?.amount}</p>\n <div>\n $\n <input\n min=\"1\"\n max=\"9999\"\n type=\"number\"\n id=\"amount\"\n name=\"amount\"\n ?required=${true}\n @focus=${() => this.clearStatusMessaging()}\n @input=${(e: Event) => {\n const newAmount = Number((e.target as HTMLInputElement).value);\n this.captureAmountChanges(newAmount);\n this.newAmount = newAmount;\n }}\n />\n / month\n </div>\n <div>\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"cover-fees\"\n tabindex=\"0\"\n @change=${(e: Event) => {\n const input = e.target as HTMLInputElement;\n const coverFees = input.checked;\n this.coverFees = coverFees;\n this.captureAmountChanges();\n }}\n />\n <label for=\"cover-fees\">${this.coveredFeesText}</label>\n </div>\n <p>Total: USD $${this.totalAmountWithFees()}</p>\n <div class=\"cta-container\">\n <ia-mgc-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-mgc-button>\n <ia-mgc-button\n id=\"update-amount\"\n class=\"ia-button primary\"\n type=\"submit\"\n .clickHandler=${(e: Event, iaButton: MGCButton) =>\n this.handleSubmit(e, iaButton)}\n >\n Update\n </ia-mgc-button>\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </div>\n </div>\n <p class=\"error\">${this.errorMessage}</p>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n input#amount {\n width: 50px;\n }\n\n .cta-container {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-content: center;\n justify-content: flex-start;\n align-items: center;\n gap: 10px;\n }\n\n p.error {\n color: var(--mgc-warning-color-dark, #bb0505);\n }\n\n ia-mgc-update-status {\n display: inline-block;\n margin-left: 1rem;\n }\n\n .checkbox-option-container {\n margin: 10px 0;\n display: flex;\n }\n `;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/form-sections/amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,OAAO,EACP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,wCAAwC,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,YAAY,GACb,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,yCAAyC,CAAC;AACjD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,qCAAqC,CAAC;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAMuB,cAAS,GAAW,CAAC,CAAC;QAEN,qBAAgB,GAAY,KAAK,CAAC;QAEjD,cAAS,GAAY,KAAK,CAAC;QAE5B,kBAAa,GAAW,EAAE,CAAC;QAE3B,iBAAY,GAAW,EAAE,CAAC;QAE1B,iBAAY,GAA4B,EAAE,CAAC;IA2UzE,CAAC;IAvUC,OAAO,CAAC,OAAuB;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC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AAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAA4B;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAA4B;AAE3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA2B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA4C;AAExD;IAAd,KAAK,CAAC,MAAM,CAAC;+CAAwB;AAlB3B,iBAAiB;IAD7B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,iBAAiB,CA2V7B","sourcesContent":["import {\n LitElement,\n html,\n PropertyValues,\n nothing,\n css,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport '@internetarchive/donation-form-section';\nimport {\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\n\nimport type { MonthlyPlan } from '../models/plan';\nimport { formatCurrency, currencyToSymbol } from '../utils/currency-format';\nimport '../presentational/donation-section-info';\nimport '../presentational/mgc-button';\nimport type { MGCButton } from '../presentational/mgc-button';\nimport '../presentational/mgc-update-status';\n\n@customElement('ia-mgc-edit-plan-amount')\nexport class MGCEditPlanAmount extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n // captures the changes made to the amount && calculates the total amount with fees\n @property({ type: Object }) donationPaymentInfo?: DonationPaymentInfo;\n\n @property({ type: Number }) newAmount: number = 0;\n\n @property({ type: Boolean, reflect: true }) currentlyEditing: boolean = false;\n\n @property({ type: Boolean }) coverFees: boolean = false;\n\n @property({ type: String }) updateMessage: string = '';\n\n @property({ type: String }) errorMessage: string = '';\n\n @property({ type: String }) updateStatus: 'success' | 'fail' | '' = '';\n\n @query('form') form!: HTMLFormElement;\n\n updated(changed: PropertyValues) {\n if (changed.has('plan') && this.plan) {\n this.captureAmountChanges();\n }\n if (changed.has('coverFees')) {\n this.captureAmountChanges();\n }\n if (changed.has('currentlyEditing') && this.currentlyEditing) {\n this.form.focus();\n }\n\n if (changed.has('donationPaymentInfo') && !this.donationPaymentInfo) {\n this.captureAmountChanges();\n }\n }\n\n protected render() {\n return html`\n <section>\n <donation-form-section badgemode=\"hidebadge\" headline=\"Amount\">\n ${!this.currentlyEditing\n ? html`<ia-mgc-form-section-info\n @editingRequested=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n ><span\n >${this.plan?.currency} ${this.plan?.amountFormatted}</span\n >\n </ia-mgc-form-section-info>`\n : nothing}\n ${this.currentlyEditing ? this.editAmountForm : nothing}\n </donation-form-section>\n </section>\n `;\n }\n\n /* External Function that is called by consumer to tell the form there has been data update */\n async amountUpdated(status: 'success' | 'fail') {\n this.clearInputField();\n\n this.updateStatus = status;\n this.updateMessage =\n status === 'success'\n ? 'Amount updated'\n : 'Failed to update date, please try again';\n\n if (status === 'success') {\n this.closeForm();\n await this.updateComplete;\n\n this.updateStatus = status;\n this.updateMessage = 'Amount updated';\n\n return;\n }\n\n (\n this.form.querySelector('ia-mgc-button#update-amount') as MGCButton\n ).isDisabled = false;\n\n this.captureAmountChanges();\n\n await this.updateComplete;\n }\n\n /* Dispatches amount change request */\n requestAmountUpdate(e: Event): void {\n e.preventDefault();\n\n const input = this.form.querySelector(\n 'input[name=\"amount\"]',\n ) as HTMLInputElement;\n this.newAmount = Number(input.value);\n\n this.captureAmountChanges(this.newAmount);\n\n console.log('<plan-amount> - update amount', {\n newValue: this.newAmount,\n oldValue: this.plan?.plan.amount,\n display: this.donationPaymentInfo?.amount,\n });\n const newAmount = Number(\n DonationPaymentInfo.calculateTotal(\n Number(this.donationPaymentInfo?.amount),\n this.coverFees,\n ),\n );\n this.dispatchEvent(\n new CustomEvent('updateAmount', {\n detail: {\n plan: this.plan,\n amount: newAmount,\n baseAmount: this.donationPaymentInfo?.amount,\n coverFees: this.coverFees,\n feeCovered: this.donationPaymentInfo?.feeAmountCovered,\n },\n }),\n );\n }\n\n /* captures form changes */\n captureAmountChanges(newAmount?: number) {\n if (!this.donationPaymentInfo && this.plan) {\n this.donationPaymentInfo = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: 0,\n coverFees: true,\n });\n return;\n }\n\n let newPlan;\n if (newAmount) {\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: newAmount,\n coverFees: true,\n });\n } else {\n const amount = this.donationPaymentInfo\n ? this.donationPaymentInfo.amount\n : this.plan!.amount;\n\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount,\n coverFees: true,\n });\n }\n\n this.donationPaymentInfo = newPlan;\n }\n\n closeForm() {\n this.clearInputField();\n this.clearStatusMessaging();\n this.currentlyEditing = false;\n this.coverFees = false;\n this.errorMessage = '';\n }\n\n clearInputField() {\n const input = this.form.querySelector(\n 'input[name=\"amount\"]',\n ) as HTMLInputElement;\n input.value = '';\n this.newAmount = 0;\n this.donationPaymentInfo = undefined;\n }\n\n handleSubmit(e: Event, iaButton?: MGCButton) {\n e.preventDefault();\n this.clearStatusMessaging();\n\n const button =\n iaButton ?? (this.form.querySelector('#update-amount') as MGCButton);\n if (button) this.updateButtonState(button);\n\n if (!this.newAmount) {\n this.errorMessage = 'Please enter a new amount';\n if (button) button.isDisabled = false;\n return;\n }\n\n const input = this.form.querySelector(\n 'input[name=\"amount\"]',\n ) as HTMLInputElement;\n const requestedAmount = Number(input.value) ?? 0;\n const amountTooLow = requestedAmount < 1;\n const amountTooHigh = requestedAmount >= 9999;\n\n if (amountTooLow) {\n this.errorMessage = 'Please enter a valid amount';\n }\n\n if (amountTooHigh) {\n this.errorMessage =\n 'Amount must be less than $9,999. Would you like to donate more? Please contact us at donations@archive.org';\n }\n\n if (amountTooHigh || amountTooLow) {\n if (button) this.updateButtonState(button);\n return;\n }\n\n this.requestAmountUpdate(e);\n }\n\n private async updateButtonState(iaButton: MGCButton) {\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton?.updateComplete;\n }\n\n async clearStatusMessaging() {\n this.errorMessage = '';\n this.updateMessage = '';\n this.updateStatus = '';\n await this.updateComplete;\n }\n\n /* DISPLAY */\n totalAmountWithFees(): number {\n if (this.newAmount === 0) {\n return 0;\n }\n\n return DonationPaymentInfo.calculateTotal(this.newAmount, this.coverFees);\n }\n\n get coveredFeesText() {\n if (!this.newAmount) {\n return \"I'll generously cover the fees.\";\n }\n const fee = DonationPaymentInfo.calculateFeeAmount(this.newAmount);\n return `I'll generously add ${formatCurrency(fee)} to cover fees.`;\n }\n\n get editAmountForm(): TemplateResult {\n return html`\n <section>\n <form\n id=\"edit-plan-amount\"\n @submit=${(e: Event) => this.handleSubmit(e)}\n >\n <p>\n Current donation amount: ${this.plan?.currency}\n ${this.plan?.amountFormatted}\n </p>\n <div>\n ${currencyToSymbol[this.plan?.currency ?? 'USD']}\n <input\n min=\"1\"\n max=\"9999\"\n type=\"number\"\n id=\"amount\"\n name=\"amount\"\n ?required=${true}\n @focus=${() => this.clearStatusMessaging()}\n @input=${(e: Event) => {\n const newAmount = Number((e.target as HTMLInputElement).value);\n this.captureAmountChanges(newAmount);\n this.newAmount = newAmount;\n }}\n />\n / month\n </div>\n <div>\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"cover-fees\"\n tabindex=\"0\"\n @change=${(e: Event) => {\n const input = e.target as HTMLInputElement;\n const coverFees = input.checked;\n this.coverFees = coverFees;\n this.captureAmountChanges();\n }}\n />\n <label for=\"cover-fees\">${this.coveredFeesText}</label>\n </div>\n <p>\n Total: ${this.plan?.currency}\n ${formatCurrency(this.totalAmountWithFees())}\n </p>\n <div class=\"cta-container\">\n <ia-mgc-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-mgc-button>\n <ia-mgc-button\n id=\"update-amount\"\n class=\"ia-button primary\"\n type=\"submit\"\n ?isDisabled=${!this.newAmount}\n .clickHandler=${(e: Event, iaButton: MGCButton) =>\n this.handleSubmit(e, iaButton)}\n >\n Update\n </ia-mgc-button>\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </div>\n </div>\n <p class=\"error\">${this.errorMessage}</p>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n input#amount {\n width: 50px;\n }\n\n .cta-container {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-content: center;\n justify-content: flex-start;\n align-items: center;\n gap: 10px;\n }\n\n p.error {\n color: var(--mgc-warning-color-dark, #bb0505);\n }\n\n ia-mgc-update-status {\n display: inline-block;\n margin-left: 1rem;\n }\n\n .checkbox-option-container {\n margin: 10px 0;\n display: flex;\n }\n `;\n}\n"]}
|
|
@@ -9,7 +9,7 @@ export declare class IauxMgcCancelPlan extends LitElement {
|
|
|
9
9
|
updated(changed: PropertyValues): void;
|
|
10
10
|
cancelThisPlan(e: Event): Promise<void>;
|
|
11
11
|
get formId(): string;
|
|
12
|
-
protected render(): typeof nothing | TemplateResult
|
|
12
|
+
protected render(): typeof nothing | TemplateResult;
|
|
13
13
|
get confirmCancelation(): TemplateResult | typeof nothing;
|
|
14
14
|
static styles: import("lit").CSSResult;
|
|
15
15
|
}
|
|
@@ -27,9 +27,18 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
27
27
|
return this.confirmCancelation;
|
|
28
28
|
}
|
|
29
29
|
return html `
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
<donation-form-section
|
|
31
|
+
badgemode="hidebadge"
|
|
32
|
+
headline="Cancel recurring donation (requires confirmation)"
|
|
33
|
+
>
|
|
34
|
+
<div class="warning">
|
|
35
|
+
<p>
|
|
36
|
+
You can also pause your recurring donation by setting the next
|
|
37
|
+
donation date up to 12 months in the future.
|
|
38
|
+
</p>
|
|
39
|
+
<ia-mgc-button
|
|
40
|
+
class="link cancel"
|
|
41
|
+
.clickHandler=${(e, iaButton) => {
|
|
33
42
|
// eslint-disable-next-line no-param-reassign
|
|
34
43
|
iaButton.isDisabled = true;
|
|
35
44
|
if (this.initialCancelRequest) {
|
|
@@ -39,20 +48,10 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
39
48
|
}
|
|
40
49
|
this.initialCancelRequest = true;
|
|
41
50
|
}}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
>
|
|
47
|
-
<div class="warning">
|
|
48
|
-
<p>
|
|
49
|
-
You can also pause your recurring donation by setting the next
|
|
50
|
-
donation date up to 12 months in the future.
|
|
51
|
-
</p>
|
|
52
|
-
<p>Let's cancel my donation</p>
|
|
53
|
-
</div>
|
|
54
|
-
</donation-form-section>
|
|
55
|
-
</ia-mgc-button>
|
|
51
|
+
>Let's cancel my donation</ia-mgc-button
|
|
52
|
+
>
|
|
53
|
+
</div>
|
|
54
|
+
</donation-form-section>
|
|
56
55
|
|
|
57
56
|
${this.initialCancelRequest ? this.confirmCancelation : nothing}
|
|
58
57
|
`;
|
|
@@ -129,6 +128,10 @@ IauxMgcCancelPlan.styles = css `
|
|
|
129
128
|
right: -10px;
|
|
130
129
|
}
|
|
131
130
|
|
|
131
|
+
ia-mgc-button.link.cancel {
|
|
132
|
+
--link-cancel-color: var(--mgc-warning-color-dark, #bb0505);
|
|
133
|
+
}
|
|
134
|
+
|
|
132
135
|
ia-mgc-button {
|
|
133
136
|
--button-height: auto;
|
|
134
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/form-sections/cancel.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAGJ,OAAO,EACP,GAAG,GACJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKnE,OAAO,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"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AAEH;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gEAA8B;AAE7B;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+DAA8B;AAE1D;IAAd,KAAK,CAAC,MAAM,CAAC;+CAAwB;AAP3B,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CA2J7B","sourcesContent":["import {\n LitElement,\n html,\n TemplateResult,\n PropertyValues,\n nothing,\n css,\n} from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport type { MonthlyPlan } from '../models/plan';\n\nimport type { MGCButton } from '../presentational/mgc-button';\n\nimport '@internetarchive/donation-form-section';\n\n@customElement('ia-mgc-cancel-plan')\nexport class IauxMgcCancelPlan extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n @property({ type: Boolean, reflect: true }) patronWantsToKeepPlan = true;\n\n @property({ type: Boolean, reflect: true }) initialCancelRequest = false;\n\n @query('form') form!: HTMLFormElement;\n\n updated(changed: PropertyValues) {\n if (changed.has('plan')) {\n console.log('plan updated', this.plan);\n }\n }\n\n async cancelThisPlan(e: Event) {\n e.preventDefault();\n this.patronWantsToKeepPlan = false;\n this.dispatchEvent(new Event('cancelPlan'));\n }\n\n get formId(): string {\n return `cancel-donation-form-${this.plan?.id}`;\n }\n\n protected render() {\n if (this.initialCancelRequest) {\n return this.confirmCancelation;\n }\n\n return html`\n <donation-form-section\n badgemode=\"hidebadge\"\n headline=\"Cancel recurring donation (requires confirmation)\"\n >\n <div class=\"warning\">\n <p>\n You can also pause your recurring donation by setting the next\n donation date up to 12 months in the future.\n </p>\n <ia-mgc-button\n class=\"link cancel\"\n .clickHandler=${(e: Event, iaButton: MGCButton) => {\n // eslint-disable-next-line no-param-reassign\n iaButton.isDisabled = true;\n if (this.initialCancelRequest) {\n this.initialCancelRequest = false;\n this.patronWantsToKeepPlan = true;\n return;\n }\n this.initialCancelRequest = true;\n }}\n >Let's cancel my donation</ia-mgc-button\n >\n </div>\n </donation-form-section>\n\n ${this.initialCancelRequest ? this.confirmCancelation : nothing}\n `;\n }\n\n get confirmCancelation(): TemplateResult | typeof nothing {\n return html`\n <section class=\"cancel-donation\">\n <donation-form-section badgemode=\"hidebadge\" headline=\"Cancel recurring donation\">\n\n <ia-mgc-button class='text exit-cancel' @click=${() => {\n this.initialCancelRequest = false;\n this.patronWantsToKeepPlan = true;\n }}>X</ia-mgc-button>\n\n <p>Canceling ends your monthly recurring donation to the Internet Archive, effective immediately. You will not be charged moving forward.</p>\n <p>Canceling does not affect your account or access to the Internet Archive, although you will no longer have access to any of the Monthly Giving Circle perks.</p>\n <p>If you have any questions regarding donations, contact us at <a href=\"mailto:donations@archive.org\">donations@archive.org</a></p>\n\n <form id=${this.formId} @submit=${(e: Event) => this.cancelThisPlan(e)}>\n <div class=\"checkbox-option-container\">\n <input\n id=${`confirm-${this.formId}`}\n type=\"checkbox\"\n required\n @change=${async (e: Event) => {\n e.preventDefault();\n this.patronWantsToKeepPlan = !(e.target as HTMLInputElement)\n .checked;\n await this.updateComplete;\n }}>\n <label for=${`confirm-${this.formId}`}><b>I'm sure I want to cancel my subscription</b></label>\n </div>\n\n <ia-mgc-button\n class=\"cancel\"\n .isDisabled=${this.patronWantsToKeepPlan}\n id=${`submit-${this.formId}`}\n type=\"submit\"\n .clickHandler=${(e: Event, iaButton: MGCButton) => {\n // eslint-disable-next-line no-param-reassign\n iaButton.isDisabled = true;\n this.cancelThisPlan(e);\n }}\n >I'm sure I want to cancel my recurring donation.</ia-mgc-button>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n :host {\n --formSectionTitleFontSize: 1.4rem;\n }\n .warning > * {\n margin: 5px 0;\n }\n\n .cancel-donation {\n display: block;\n border: 2px solid #d9534f;\n background-color: #ffeeee;\n }\n\n .cancel-donation > * {\n padding: 5px;\n position: relative;\n }\n\n ia-mgc-button.exit-cancel {\n --button-border: 1px solid;\n --button-border-radius: 50%;\n position: absolute;\n top: -5px;\n right: -10px;\n }\n\n ia-mgc-button.link.cancel {\n --link-cancel-color: var(--mgc-warning-color-dark, #bb0505);\n }\n\n ia-mgc-button {\n --button-height: auto;\n }\n\n ia-mgc-button > * {\n text-align: left;\n text-wrap: wrap;\n }\n\n h3 {\n position: relative;\n }\n\n .checkbox-option-container {\n display: flex;\n margin: 10px 0;\n }\n `;\n}\n"]}
|
|
@@ -4,7 +4,8 @@ import type { MonthlyPlan } from '../models/plan';
|
|
|
4
4
|
import '../presentational/mgc-button';
|
|
5
5
|
import type { MGCButton } from '../presentational/mgc-button';
|
|
6
6
|
import '../presentational/mgc-update-status';
|
|
7
|
-
|
|
7
|
+
import '../presentational/donation-section-info';
|
|
8
|
+
type InvalidDateErrorCode = 'invalid_date' | 'date_too_early' | 'second_donation_this_month' | 'date_out_of_range' | 'same_next_billing_date' | '';
|
|
8
9
|
export declare class MGCEditPlanDate extends LitElement {
|
|
9
10
|
plan?: MonthlyPlan;
|
|
10
11
|
newDate?: string;
|
|
@@ -4,6 +4,7 @@ import { customElement, property, query } from 'lit/decorators.js';
|
|
|
4
4
|
import '@internetarchive/donation-form-section';
|
|
5
5
|
import '../presentational/mgc-button';
|
|
6
6
|
import '../presentational/mgc-update-status';
|
|
7
|
+
import '../presentational/donation-section-info';
|
|
7
8
|
var InvalidDateErrorMessages;
|
|
8
9
|
(function (InvalidDateErrorMessages) {
|
|
9
10
|
InvalidDateErrorMessages["invalid_date"] = "Please enter a valid date format (YYYY-MM-DD)";
|
|
@@ -295,6 +296,7 @@ MGCEditPlanDate.styles = css `
|
|
|
295
296
|
input[name='edit-date'] {
|
|
296
297
|
margin: 10px 0;
|
|
297
298
|
min-width: 140px;
|
|
299
|
+
font-family: inherit;
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
.cta-container {
|