@internetarchive/donation-monthly-portal 6.0.0 → 7.0.1-alpha1
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/dist/src/edit-plan-form.d.ts +3 -2
- package/dist/src/edit-plan-form.js +25 -4
- package/dist/src/edit-plan-form.js.map +1 -1
- package/dist/src/form-sections/amount.d.ts +1 -1
- package/dist/src/form-sections/amount.js +10 -8
- package/dist/src/form-sections/amount.js.map +1 -1
- package/dist/src/form-sections/cancel.js +9 -9
- package/dist/src/form-sections/cancel.js.map +1 -1
- package/dist/src/form-sections/date.d.ts +38 -0
- package/dist/src/form-sections/date.js +370 -0
- package/dist/src/form-sections/date.js.map +1 -0
- package/dist/src/models/plan.d.ts +9 -1
- package/dist/src/models/plan.js +18 -4
- package/dist/src/models/plan.js.map +1 -1
- package/dist/src/monthly-giving-circle.d.ts +2 -2
- package/dist/src/monthly-giving-circle.js +21 -11
- package/dist/src/monthly-giving-circle.js.map +1 -1
- package/dist/src/plans.d.ts +1 -1
- package/dist/src/plans.js +4 -4
- package/dist/src/plans.js.map +1 -1
- package/dist/src/presentational/{ia-button.d.ts → mgc-button.d.ts} +2 -2
- package/dist/src/presentational/{ia-button.js → mgc-button.js} +10 -10
- package/dist/src/presentational/mgc-button.js.map +1 -0
- package/dist/src/receipts.d.ts +1 -1
- package/dist/src/receipts.js +8 -8
- package/dist/src/receipts.js.map +1 -1
- package/dist/test/edit-plan-form.test.js +12 -6
- package/dist/test/edit-plan-form.test.js.map +1 -1
- package/dist/test/form-sections/amount.test.js +6 -1
- package/dist/test/form-sections/amount.test.js.map +1 -1
- package/dist/test/form-sections/date.test.d.ts +1 -0
- package/dist/test/form-sections/date.test.js +136 -0
- package/dist/test/form-sections/date.test.js.map +1 -0
- package/dist/test/monthly-giving-circle.test.js +9 -4
- package/dist/test/monthly-giving-circle.test.js.map +1 -1
- package/dist/test/receipt-email-request-flow.test.js +2 -2
- package/dist/test/receipt-email-request-flow.test.js.map +1 -1
- package/package.json +1 -1
- package/src/edit-plan-form.ts +29 -3
- package/src/form-sections/amount.ts +14 -12
- package/src/form-sections/cancel.ts +12 -12
- package/src/form-sections/date.ts +401 -0
- package/src/models/plan.ts +30 -4
- package/src/monthly-giving-circle.ts +25 -13
- package/src/plans.ts +6 -6
- package/src/presentational/{ia-button.ts → mgc-button.ts} +3 -3
- package/src/receipts.ts +10 -10
- package/dist/src/presentational/ia-button.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import type { MonthlyPlan } from './models/plan';
|
|
3
|
-
import './form-sections/cancel';
|
|
4
3
|
import './form-sections/amount';
|
|
4
|
+
import './form-sections/date';
|
|
5
|
+
import './form-sections/cancel';
|
|
5
6
|
export declare class IauxEditPlanForm extends LitElement {
|
|
6
7
|
plan?: MonthlyPlan;
|
|
7
|
-
cancelPlanHandler?: (plan: MonthlyPlan) => void;
|
|
8
8
|
updateAmountHandler?: (plan: MonthlyPlan, amountUpdates: {
|
|
9
9
|
amount: number;
|
|
10
10
|
baseAmount: number;
|
|
@@ -13,6 +13,7 @@ export declare class IauxEditPlanForm extends LitElement {
|
|
|
13
13
|
}) => void;
|
|
14
14
|
createRenderRoot(): this;
|
|
15
15
|
amountUpdates(status: 'success' | 'fail'): void;
|
|
16
|
+
dateUpdates(status: 'success' | 'fail'): void;
|
|
16
17
|
render(): import("lit").TemplateResult<1>;
|
|
17
18
|
mailToText(): string;
|
|
18
19
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import './form-sections/cancel';
|
|
5
4
|
import './form-sections/amount';
|
|
5
|
+
import './form-sections/date';
|
|
6
|
+
import './form-sections/cancel';
|
|
6
7
|
let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
7
8
|
createRenderRoot() {
|
|
8
9
|
return this;
|
|
@@ -11,6 +12,10 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
11
12
|
const amountForm = this.querySelector('ia-mgc-edit-plan-amount');
|
|
12
13
|
amountForm.amountUpdated(status);
|
|
13
14
|
}
|
|
15
|
+
dateUpdates(status) {
|
|
16
|
+
const dateForm = this.querySelector('ia-mgc-edit-date');
|
|
17
|
+
dateForm.dateUpdated(status);
|
|
18
|
+
}
|
|
14
19
|
render() {
|
|
15
20
|
return html `
|
|
16
21
|
<section class="mgc-edit-plan">
|
|
@@ -30,6 +35,25 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
30
35
|
}}
|
|
31
36
|
></ia-mgc-edit-plan-amount>
|
|
32
37
|
<hr />
|
|
38
|
+
<ia-mgc-edit-date
|
|
39
|
+
@updateDate=${(e) => {
|
|
40
|
+
const { newDate } = e.detail;
|
|
41
|
+
if (this.plan) {
|
|
42
|
+
this.dispatchEvent(new CustomEvent('updateDate', {
|
|
43
|
+
detail: { plan: this.plan, newDate },
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
.plan=${this.plan}
|
|
48
|
+
></ia-mgc-edit-date>
|
|
49
|
+
<hr />
|
|
50
|
+
<ia-mgc-cancel-plan
|
|
51
|
+
.plan=${this.plan}
|
|
52
|
+
@cancelPlan=${() => {
|
|
53
|
+
this.dispatchEvent(new Event('cancelPlan'));
|
|
54
|
+
}}
|
|
55
|
+
></ia-mgc-cancel-plan>
|
|
56
|
+
<hr />
|
|
33
57
|
<p class="email-edit-plan">
|
|
34
58
|
Need to update your plan further? Please email us at
|
|
35
59
|
<a href=${this.mailToText}>donations@archive.org</a>.
|
|
@@ -44,9 +68,6 @@ let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
|
44
68
|
__decorate([
|
|
45
69
|
property({ type: Object })
|
|
46
70
|
], IauxEditPlanForm.prototype, "plan", void 0);
|
|
47
|
-
__decorate([
|
|
48
|
-
property({ type: Object })
|
|
49
|
-
], IauxEditPlanForm.prototype, "cancelPlanHandler", void 0);
|
|
50
71
|
__decorate([
|
|
51
72
|
property({ type: Object })
|
|
52
73
|
], 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,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,wBAAwB,CAAC;AAChC,OAAO,wBAAwB,CAAC;
|
|
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,MAAM,mBAAmB,CAAC;AAG5D,OAAO,wBAAwB,CAAC;AAChC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,wBAAwB,CAAC;AAKhC,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IAa9C,gBAAgB;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAA0B;QACtC,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CACnC,yBAAyB,CACL,CAAC;QACvB,UAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,WAAW,CAAC,MAA0B;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,kBAAkB,CAAoB,CAAC;QAC3E,QAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;kBAGG,IAAI,CAAC,IAAI;0BACD,CAAC,CAAc,EAAE,EAAE;;YACjC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;YAC/D,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,MAAA,IAAI,CAAC,mBAAmB,qDAAG,IAAI,CAAC,IAAI,EAAE;oBACpC,MAAM;oBACN,UAAU;oBACV,SAAS;oBACT,UAAU;iBACX,CAAC,CAAC;aACJ;QACH,CAAC;;;;wBAIa,CAAC,CAAc,EAAE,EAAE;YAC/B,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;YAC7B,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,YAAY,EAAE;oBAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE;iBACrC,CAAC,CACH,CAAC;aACH;QACH,CAAC;kBACO,IAAI,CAAC,IAAI;;;;kBAIT,IAAI,CAAC,IAAI;wBACH,GAAG,EAAE;YACjB,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAC9C,CAAC;;;;;oBAKS,IAAI,CAAC,UAAU;;;KAG9B,CAAC;IACJ,CAAC;IAED,UAAU;QACR,OAAO,6EAA6E,CAAC;IACvF,CAAC;CACF,CAAA;AA9E6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAQjB;AAXC,gBAAgB;IAD5B,aAAa,CAAC,kBAAkB,CAAC;GACrB,gBAAgB,CA+E5B;SA/EY,gBAAgB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport type { MonthlyPlan } from './models/plan';\nimport './form-sections/amount';\nimport './form-sections/date';\nimport './form-sections/cancel';\nimport type { MGCEditPlanAmount } from './form-sections/amount';\nimport type { MGCEditPlanDate } from './form-sections/date';\n\n@customElement('ia-mgc-edit-plan')\nexport class IauxEditPlanForm extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\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 createRenderRoot() {\n return this;\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 <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"]}
|
|
@@ -2,7 +2,7 @@ import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
|
2
2
|
import '@internetarchive/donation-form-section';
|
|
3
3
|
import { DonationPaymentInfo } from '@internetarchive/donation-form-data-models';
|
|
4
4
|
import type { MonthlyPlan } from '../models/plan';
|
|
5
|
-
import '../presentational/
|
|
5
|
+
import '../presentational/mgc-button';
|
|
6
6
|
import '../presentational/mgc-update-status';
|
|
7
7
|
export declare class MGCEditPlanAmount extends LitElement {
|
|
8
8
|
plan?: MonthlyPlan;
|
|
@@ -3,7 +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 '../presentational/
|
|
6
|
+
import '../presentational/mgc-button';
|
|
7
7
|
import '../presentational/mgc-update-status';
|
|
8
8
|
let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
9
9
|
constructor() {
|
|
@@ -41,7 +41,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
41
41
|
>${this.updateMessage}</ia-mgc-update-status
|
|
42
42
|
>
|
|
43
43
|
</p>
|
|
44
|
-
<ia-button
|
|
44
|
+
<ia-mgc-button
|
|
45
45
|
id="edit-amount"
|
|
46
46
|
class="ia-button link"
|
|
47
47
|
.clickHandler=${() => {
|
|
@@ -50,7 +50,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
50
50
|
}}
|
|
51
51
|
>
|
|
52
52
|
Edit...
|
|
53
|
-
</ia-button>`
|
|
53
|
+
</ia-mgc-button>`
|
|
54
54
|
: nothing}
|
|
55
55
|
${this.currentlyEditing ? this.editAmountForm : nothing}
|
|
56
56
|
</donation-form-section>
|
|
@@ -70,7 +70,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
70
70
|
this.updateMessage = 'Amount updated';
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
this.form.querySelector('ia-button#update-amount').isDisabled = false;
|
|
73
|
+
this.form.querySelector('ia-mgc-button#update-amount').isDisabled = false;
|
|
74
74
|
this.captureAmountChanges();
|
|
75
75
|
await this.updateComplete;
|
|
76
76
|
}
|
|
@@ -166,6 +166,8 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
166
166
|
<div>
|
|
167
167
|
$
|
|
168
168
|
<input
|
|
169
|
+
min="1"
|
|
170
|
+
max="9999"
|
|
169
171
|
type="number"
|
|
170
172
|
id="amount"
|
|
171
173
|
name="amount"
|
|
@@ -196,7 +198,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
196
198
|
</div>
|
|
197
199
|
<p>Total: USD $${this.totalAmountWithFees()}</p>
|
|
198
200
|
<div class="cta-container">
|
|
199
|
-
<ia-button
|
|
201
|
+
<ia-mgc-button
|
|
200
202
|
class="ia-button secondary"
|
|
201
203
|
.clickHandler=${(e) => {
|
|
202
204
|
e.preventDefault();
|
|
@@ -204,8 +206,8 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
204
206
|
}}
|
|
205
207
|
>
|
|
206
208
|
Cancel
|
|
207
|
-
</ia-button>
|
|
208
|
-
<ia-button
|
|
209
|
+
</ia-mgc-button>
|
|
210
|
+
<ia-mgc-button
|
|
209
211
|
id="update-amount"
|
|
210
212
|
class="ia-button primary"
|
|
211
213
|
type="submit"
|
|
@@ -241,7 +243,7 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
|
|
|
241
243
|
}}
|
|
242
244
|
>
|
|
243
245
|
Update
|
|
244
|
-
</ia-button>
|
|
246
|
+
</ia-mgc-button>
|
|
245
247
|
<ia-mgc-update-status .status=${this.updateStatus}
|
|
246
248
|
>${this.updateMessage}</ia-mgc-update-status
|
|
247
249
|
>
|
|
@@ -1 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AA5B,QAAQ,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,CAqU7B;SArUY,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/ia-button';\nimport type { IauxButton } from '../presentational/ia-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` <p class=\"current-amount\">\n USD $${this.plan?.amount}\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </p>\n <ia-button\n id=\"edit-amount\"\n class=\"ia-button link\"\n .clickHandler=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n >\n Edit...\n </ia-button>`\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. 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-button#update-amount') as IauxButton\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 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 id=\"edit-plan-amount\">\n <p>Current donation amount: $${this.plan?.amount}</p>\n <div>\n $\n <input\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-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-button>\n <ia-button\n id=\"update-amount\"\n class=\"ia-button primary\"\n type=\"submit\"\n .clickHandler=${async (e: Event, iaButton: IauxButton) => {\n this.clearStatusMessaging();\n\n if (!this.newAmount) {\n this.errorMessage = 'Please enter a new amount';\n return;\n }\n\n // eslint-disable-next-line no-param-reassign\n (iaButton as IauxButton).isDisabled = true;\n await iaButton.updateComplete;\n\n // check if request is in range\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 if (amountTooLow) {\n this.errorMessage = 'Please enter a valid amount';\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 if (amountTooHigh || amountTooLow) {\n // eslint-disable-next-line no-param-reassign\n (iaButton as IauxButton).isDisabled = false;\n await iaButton.updateComplete;\n return;\n }\n\n this.requestAmountUpdate(e);\n }}\n >\n Update\n </ia-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,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;QAE5B,kBAAa,GAAW,EAAE,CAAC;QAE3B,iBAAY,GAAW,EAAE,CAAC;QAE1B,iBAAY,GAA4B,EAAE,CAAC;IAuTzE,CAAC;IAnTC,OAAO,CAAC,OAAuB;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE;YACpC,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC5D,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;SACnB;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YACnE,IAAI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CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DAAmC;AAEjD;IAA5B,QAAQ,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,CAuU7B;SAvUY,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/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` <p class=\"current-amount\">\n USD $${this.plan?.amount}\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </p>\n <ia-mgc-button\n id=\"edit-amount\"\n class=\"ia-button link\"\n .clickHandler=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n >\n Edit...\n </ia-mgc-button>`\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. 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 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 id=\"edit-plan-amount\">\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=${async (e: Event, iaButton: MGCButton) => {\n this.clearStatusMessaging();\n\n if (!this.newAmount) {\n this.errorMessage = 'Please enter a new amount';\n return;\n }\n\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton.updateComplete;\n\n // check if request is in range\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 if (amountTooLow) {\n this.errorMessage = 'Please enter a valid amount';\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 if (amountTooHigh || amountTooLow) {\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = false;\n await iaButton.updateComplete;\n return;\n }\n\n this.requestAmountUpdate(e);\n }}\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"]}
|
|
@@ -28,7 +28,7 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
28
28
|
return this.confirmCancelation;
|
|
29
29
|
}
|
|
30
30
|
return html `
|
|
31
|
-
<ia-button
|
|
31
|
+
<ia-mgc-button
|
|
32
32
|
class="clear-container slim"
|
|
33
33
|
.clickHandler=${(e, iaButton) => {
|
|
34
34
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -53,7 +53,7 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
53
53
|
<p>Let's cancel my donation</p>
|
|
54
54
|
</div>
|
|
55
55
|
</donation-form-section>
|
|
56
|
-
</ia-button>
|
|
56
|
+
</ia-mgc-button>
|
|
57
57
|
|
|
58
58
|
${this.initialCancelRequest ? this.confirmCancelation : nothing}
|
|
59
59
|
`;
|
|
@@ -63,10 +63,10 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
63
63
|
<section class="cancel-donation">
|
|
64
64
|
<donation-form-section badgemode="hidebadge" headline="Cancel recurring donation">
|
|
65
65
|
|
|
66
|
-
<ia-button class='text exit-cancel' @click=${() => {
|
|
66
|
+
<ia-mgc-button class='text exit-cancel' @click=${() => {
|
|
67
67
|
this.initialCancelRequest = false;
|
|
68
68
|
this.patronWantsToKeepPlan = true;
|
|
69
|
-
}}>X</ia-button>
|
|
69
|
+
}}>X</ia-mgc-button>
|
|
70
70
|
|
|
71
71
|
<p>Canceling ends your monthly recurring donation to the Internet Archive, effective immediately. You will not be charged moving forward.</p>
|
|
72
72
|
<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>
|
|
@@ -87,7 +87,7 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
87
87
|
<label for=${`confirm-${this.formId}`}><b>I'm sure I want to cancel my subscription</b></label>
|
|
88
88
|
</div>
|
|
89
89
|
|
|
90
|
-
<ia-button
|
|
90
|
+
<ia-mgc-button
|
|
91
91
|
class="cancel"
|
|
92
92
|
.isDisabled=${this.patronWantsToKeepPlan}
|
|
93
93
|
id=${`submit-${this.formId}`}
|
|
@@ -97,7 +97,7 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
|
97
97
|
iaButton.isDisabled = true;
|
|
98
98
|
this.cancelThisPlan(e);
|
|
99
99
|
}}
|
|
100
|
-
>I'm sure I want to cancel my recurring donation.</ia-button>
|
|
100
|
+
>I'm sure I want to cancel my recurring donation.</ia-mgc-button>
|
|
101
101
|
</form>
|
|
102
102
|
</section>
|
|
103
103
|
`;
|
|
@@ -122,7 +122,7 @@ IauxMgcCancelPlan.styles = css `
|
|
|
122
122
|
position: relative;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
ia-button.exit-cancel {
|
|
125
|
+
ia-mgc-button.exit-cancel {
|
|
126
126
|
--button-border: 1px solid;
|
|
127
127
|
--button-border-radius: 50%;
|
|
128
128
|
position: absolute;
|
|
@@ -130,11 +130,11 @@ IauxMgcCancelPlan.styles = css `
|
|
|
130
130
|
right: -10px;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
ia-button {
|
|
133
|
+
ia-mgc-button {
|
|
134
134
|
--button-height: auto;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
ia-button > * {
|
|
137
|
+
ia-mgc-button > * {
|
|
138
138
|
text-align: left;
|
|
139
139
|
text-wrap: wrap;
|
|
140
140
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/form-sections/cancel.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MAAM,CAAC;+CAAwB;AAP3B,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CAwJ7B;SAxJY,iBAAiB","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';\nimport '@internetarchive/donation-form/dist/src/form-elements/contact-form/contact-form.js';\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 <ia-mgc-button\n class=\"clear-container slim\"\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 >\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 <p>Let's cancel my donation</p>\n </div>\n </donation-form-section>\n </ia-mgc-button>\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 {\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"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import '@internetarchive/donation-form-section';
|
|
3
|
+
import type { MonthlyPlan } from '../models/plan';
|
|
4
|
+
import '../presentational/mgc-button';
|
|
5
|
+
import type { MGCButton } from '../presentational/mgc-button';
|
|
6
|
+
import '../presentational/mgc-update-status';
|
|
7
|
+
declare type InvalidDateErrorCode = 'invalid_date' | 'date_too_early' | 'second_donation_this_month' | 'date_out_of_range' | 'same_next_billing_date' | '';
|
|
8
|
+
export declare class MGCEditPlanDate extends LitElement {
|
|
9
|
+
plan?: MonthlyPlan;
|
|
10
|
+
newDate?: string;
|
|
11
|
+
currentlyEditing: boolean;
|
|
12
|
+
allowEditing: boolean;
|
|
13
|
+
updateMessage: string;
|
|
14
|
+
errorMessage: string;
|
|
15
|
+
warningMessage: string;
|
|
16
|
+
updateStatus: 'success' | 'fail' | '';
|
|
17
|
+
form: HTMLFormElement;
|
|
18
|
+
formSubmitButton: MGCButton;
|
|
19
|
+
dateInput: HTMLInputElement;
|
|
20
|
+
willUpdate(changed: PropertyValues): void;
|
|
21
|
+
updated(changed: PropertyValues): void;
|
|
22
|
+
protected render(): TemplateResult<1>;
|
|
23
|
+
dateUpdated(status: 'success' | 'fail'): Promise<void>;
|
|
24
|
+
requestDateUpdate(e: Event): void;
|
|
25
|
+
closeForm(): void;
|
|
26
|
+
clearInputField(): void;
|
|
27
|
+
formatDateToYYYYMMDD(date: Date): string;
|
|
28
|
+
clearStatusMessaging(): Promise<void>;
|
|
29
|
+
validateChosenDate(dateString: string): {
|
|
30
|
+
valid: boolean;
|
|
31
|
+
errorCode: InvalidDateErrorCode | '';
|
|
32
|
+
};
|
|
33
|
+
get minDate(): string;
|
|
34
|
+
get maxDate(): string;
|
|
35
|
+
get editDateForm(): TemplateResult;
|
|
36
|
+
static styles: import("lit").CSSResult;
|
|
37
|
+
}
|
|
38
|
+
export {};
|