@internetarchive/donation-monthly-portal 4.0.0 → 6.0.0

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.
Files changed (48) hide show
  1. package/dist/src/edit-plan-form.d.ts +10 -0
  2. package/dist/src/edit-plan-form.js +29 -5
  3. package/dist/src/edit-plan-form.js.map +1 -1
  4. package/dist/src/form-sections/amount.d.ts +29 -0
  5. package/dist/src/form-sections/amount.js +316 -0
  6. package/dist/src/form-sections/amount.js.map +1 -0
  7. package/dist/src/form-sections/cancel.js +6 -2
  8. package/dist/src/form-sections/cancel.js.map +1 -1
  9. package/dist/src/models/plan.d.ts +1 -0
  10. package/dist/src/models/plan.js +4 -0
  11. package/dist/src/models/plan.js.map +1 -1
  12. package/dist/src/monthly-giving-circle.d.ts +4 -1
  13. package/dist/src/monthly-giving-circle.js +36 -13
  14. package/dist/src/monthly-giving-circle.js.map +1 -1
  15. package/dist/src/plans.d.ts +3 -0
  16. package/dist/src/plans.js +32 -15
  17. package/dist/src/plans.js.map +1 -1
  18. package/dist/src/presentational/ia-button.js +1 -0
  19. package/dist/src/presentational/ia-button.js.map +1 -1
  20. package/dist/src/presentational/mgc-title.d.ts +1 -1
  21. package/dist/src/presentational/mgc-title.js +10 -7
  22. package/dist/src/presentational/mgc-title.js.map +1 -1
  23. package/dist/src/presentational/mgc-update-status.d.ts +7 -0
  24. package/dist/src/presentational/mgc-update-status.js +53 -0
  25. package/dist/src/presentational/mgc-update-status.js.map +1 -0
  26. package/dist/src/receipts.js +6 -22
  27. package/dist/src/receipts.js.map +1 -1
  28. package/dist/src/welcome-message.js +1 -0
  29. package/dist/src/welcome-message.js.map +1 -1
  30. package/dist/test/edit-plan-form.test.js +34 -30
  31. package/dist/test/edit-plan-form.test.js.map +1 -1
  32. package/dist/test/form-sections/amount.test.d.ts +1 -0
  33. package/dist/test/form-sections/amount.test.js +44 -0
  34. package/dist/test/form-sections/amount.test.js.map +1 -0
  35. package/dist/test/monthly-giving-circle.test.js +1 -0
  36. package/dist/test/monthly-giving-circle.test.js.map +1 -1
  37. package/package.json +2 -1
  38. package/src/edit-plan-form.ts +42 -5
  39. package/src/form-sections/amount.ts +347 -0
  40. package/src/form-sections/cancel.ts +7 -3
  41. package/src/models/plan.ts +5 -0
  42. package/src/monthly-giving-circle.ts +46 -13
  43. package/src/plans.ts +35 -18
  44. package/src/presentational/ia-button.ts +1 -0
  45. package/src/presentational/mgc-title.ts +5 -2
  46. package/src/presentational/mgc-update-status.ts +47 -0
  47. package/src/receipts.ts +11 -22
  48. package/src/welcome-message.ts +1 -0
@@ -1,8 +1,18 @@
1
1
  import { LitElement } from 'lit';
2
2
  import type { MonthlyPlan } from './models/plan';
3
3
  import './form-sections/cancel';
4
+ import './form-sections/amount';
4
5
  export declare class IauxEditPlanForm extends LitElement {
5
6
  plan?: MonthlyPlan;
6
7
  cancelPlanHandler?: (plan: MonthlyPlan) => void;
8
+ updateAmountHandler?: (plan: MonthlyPlan, amountUpdates: {
9
+ amount: number;
10
+ baseAmount: number;
11
+ coverFees: boolean;
12
+ feeCovered: number;
13
+ }) => void;
14
+ createRenderRoot(): this;
15
+ amountUpdates(status: 'success' | 'fail'): void;
7
16
  render(): import("lit").TemplateResult<1>;
17
+ mailToText(): string;
8
18
  }
@@ -2,23 +2,44 @@ import { __decorate } from "tslib";
2
2
  import { LitElement, html } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
4
  import './form-sections/cancel';
5
+ import './form-sections/amount';
5
6
  let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
7
+ createRenderRoot() {
8
+ return this;
9
+ }
10
+ amountUpdates(status) {
11
+ const amountForm = this.querySelector('ia-mgc-edit-plan-amount');
12
+ amountForm.amountUpdated(status);
13
+ }
6
14
  render() {
7
15
  return html `
8
16
  <section class="mgc-edit-plan">
9
- <hr />
10
- <ia-mgc-cancel-plan
17
+ <ia-mgc-edit-plan-amount
11
18
  .plan=${this.plan}
12
- @cancelPlan=${() => {
19
+ @updateAmount=${(e) => {
13
20
  var _a;
21
+ const { amount, baseAmount, coverFees, feeCovered } = e.detail;
14
22
  if (this.plan) {
15
- (_a = this.cancelPlanHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.plan);
23
+ (_a = this.updateAmountHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.plan, {
24
+ amount,
25
+ baseAmount,
26
+ coverFees,
27
+ feeCovered,
28
+ });
16
29
  }
17
30
  }}
18
- ></ia-mgc-cancel-plan>
31
+ ></ia-mgc-edit-plan-amount>
32
+ <hr />
33
+ <p class="email-edit-plan">
34
+ Need to update your plan further? Please email us at
35
+ <a href=${this.mailToText}>donations@archive.org</a>.
36
+ </p>
19
37
  </section>
20
38
  `;
21
39
  }
40
+ mailToText() {
41
+ return `mailto:donations@archive.org?subject=I'd like to update my monthly donation`;
42
+ }
22
43
  };
23
44
  __decorate([
24
45
  property({ type: Object })
@@ -26,6 +47,9 @@ __decorate([
26
47
  __decorate([
27
48
  property({ type: Object })
28
49
  ], IauxEditPlanForm.prototype, "cancelPlanHandler", void 0);
50
+ __decorate([
51
+ property({ type: Object })
52
+ ], IauxEditPlanForm.prototype, "updateAmountHandler", void 0);
29
53
  IauxEditPlanForm = __decorate([
30
54
  customElement('ia-mgc-edit-plan')
31
55
  ], IauxEditPlanForm);
@@ -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;AAGhC,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IAK9C,MAAM;QACJ,OAAO,IAAI,CAAA;;;;kBAIG,IAAI,CAAC,IAAI;wBACH,GAAG,EAAE;;YACjB,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,MAAA,IAAI,CAAC,iBAAiB,qDAAG,IAAI,CAAC,IAAI,CAAC,CAAC;aACrC;QACH,CAAC;;;KAGN,CAAC;IACJ,CAAC;CACF,CAAA;AAnB6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAiD;AAHjE,gBAAgB;IAD5B,aAAa,CAAC,kBAAkB,CAAC;GACrB,gBAAgB,CAoB5B;SApBY,gBAAgB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport type { MonthlyPlan } from './models/plan';\nimport './form-sections/cancel';\n\n@customElement('ia-mgc-edit-plan')\nexport class IauxEditPlanForm extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n @property({ type: Object }) cancelPlanHandler?: (plan: MonthlyPlan) => void;\n\n render() {\n return html`\n <section class=\"mgc-edit-plan\">\n <hr />\n <ia-mgc-cancel-plan\n .plan=${this.plan}\n @cancelPlan=${() => {\n if (this.plan) {\n this.cancelPlanHandler?.(this.plan);\n }\n }}\n ></ia-mgc-cancel-plan>\n </section>\n `;\n }\n}\n"]}
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;AAIhC,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IAe9C,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,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;;;;;oBAKS,IAAI,CAAC,UAAU;;;KAG9B,CAAC;IACJ,CAAC;IAED,UAAU;QACR,OAAO,6EAA6E,CAAC;IACvF,CAAC;CACF,CAAA;AAtD6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAiD;AAEhD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAQjB;AAbC,gBAAgB;IAD5B,aAAa,CAAC,kBAAkB,CAAC;GACrB,gBAAgB,CAuD5B;SAvDY,gBAAgB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport type { MonthlyPlan } from './models/plan';\nimport './form-sections/cancel';\nimport './form-sections/amount';\nimport type { MGCEditPlanAmount } from './form-sections/amount';\n\n@customElement('ia-mgc-edit-plan')\nexport class IauxEditPlanForm extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n @property({ type: Object }) cancelPlanHandler?: (plan: MonthlyPlan) => void;\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 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 <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"]}
@@ -0,0 +1,29 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
+ import '@internetarchive/donation-form-section';
3
+ import { DonationPaymentInfo } from '@internetarchive/donation-form-data-models';
4
+ import type { MonthlyPlan } from '../models/plan';
5
+ import '../presentational/ia-button';
6
+ import '../presentational/mgc-update-status';
7
+ export declare class MGCEditPlanAmount extends LitElement {
8
+ plan?: MonthlyPlan;
9
+ donationPaymentInfo?: DonationPaymentInfo;
10
+ newAmount: number;
11
+ currentlyEditing: boolean;
12
+ coverFees: boolean;
13
+ updateMessage: string;
14
+ errorMessage: string;
15
+ updateStatus: 'success' | 'fail' | '';
16
+ form: HTMLFormElement;
17
+ updated(changed: PropertyValues): void;
18
+ protected render(): TemplateResult<1>;
19
+ amountUpdated(status: 'success' | 'fail'): Promise<void>;
20
+ requestAmountUpdate(e: Event): void;
21
+ captureAmountChanges(newAmount?: number): void;
22
+ closeForm(): void;
23
+ clearInputField(): void;
24
+ clearStatusMessaging(): Promise<void>;
25
+ totalAmountWithFees(): number;
26
+ get coveredFeesText(): string;
27
+ get editAmountForm(): TemplateResult;
28
+ static styles: import("lit").CSSResult;
29
+ }
@@ -0,0 +1,316 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, nothing, css, } from 'lit';
3
+ import { customElement, property, query } from 'lit/decorators.js';
4
+ import '@internetarchive/donation-form-section';
5
+ import { DonationPaymentInfo, DonationType, } from '@internetarchive/donation-form-data-models';
6
+ import '../presentational/ia-button';
7
+ import '../presentational/mgc-update-status';
8
+ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.newAmount = 0;
12
+ this.currentlyEditing = false;
13
+ this.coverFees = false;
14
+ this.updateMessage = '';
15
+ this.errorMessage = '';
16
+ this.updateStatus = '';
17
+ }
18
+ updated(changed) {
19
+ if (changed.has('plan') && this.plan) {
20
+ this.captureAmountChanges();
21
+ }
22
+ if (changed.has('coverFees')) {
23
+ this.captureAmountChanges();
24
+ }
25
+ if (changed.has('currentlyEditing') && this.currentlyEditing) {
26
+ this.form.focus();
27
+ }
28
+ if (changed.has('donationPaymentInfo') && !this.donationPaymentInfo) {
29
+ this.captureAmountChanges();
30
+ }
31
+ }
32
+ render() {
33
+ var _a;
34
+ return html `
35
+ <section>
36
+ <donation-form-section badgemode="hidebadge" headline="Amount">
37
+ ${!this.currentlyEditing
38
+ ? html ` <p class="current-amount">
39
+ USD $${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.amount}
40
+ <ia-mgc-update-status .status=${this.updateStatus}
41
+ >${this.updateMessage}</ia-mgc-update-status
42
+ >
43
+ </p>
44
+ <ia-button
45
+ id="edit-amount"
46
+ class="ia-button link"
47
+ .clickHandler=${() => {
48
+ this.currentlyEditing = true;
49
+ this.clearStatusMessaging();
50
+ }}
51
+ >
52
+ Edit...
53
+ </ia-button>`
54
+ : nothing}
55
+ ${this.currentlyEditing ? this.editAmountForm : nothing}
56
+ </donation-form-section>
57
+ </section>
58
+ `;
59
+ }
60
+ /* External Function that is called by consumer to tell the form there has been data update */
61
+ async amountUpdated(status) {
62
+ this.clearInputField();
63
+ this.updateStatus = status;
64
+ this.updateMessage =
65
+ status === 'success' ? 'Amount updated' : 'Failed. Try again.';
66
+ if (status === 'success') {
67
+ this.closeForm();
68
+ await this.updateComplete;
69
+ this.updateStatus = status;
70
+ this.updateMessage = 'Amount updated';
71
+ return;
72
+ }
73
+ this.form.querySelector('ia-button#update-amount').isDisabled = false;
74
+ this.captureAmountChanges();
75
+ await this.updateComplete;
76
+ }
77
+ /* Dispatches amount change request */
78
+ requestAmountUpdate(e) {
79
+ var _a, _b, _c, _d, _e;
80
+ e.preventDefault();
81
+ const input = this.form.querySelector('input[name="amount"]');
82
+ this.newAmount = Number(input.value);
83
+ this.captureAmountChanges(this.newAmount);
84
+ console.log('<plan-amount> - update amount', {
85
+ newValue: this.newAmount,
86
+ oldValue: (_a = this.plan) === null || _a === void 0 ? void 0 : _a.plan.amount,
87
+ display: (_b = this.donationPaymentInfo) === null || _b === void 0 ? void 0 : _b.amount,
88
+ });
89
+ const newAmount = Number(DonationPaymentInfo.calculateTotal(Number((_c = this.donationPaymentInfo) === null || _c === void 0 ? void 0 : _c.amount), this.coverFees));
90
+ this.dispatchEvent(new CustomEvent('updateAmount', {
91
+ detail: {
92
+ plan: this.plan,
93
+ amount: newAmount,
94
+ baseAmount: (_d = this.donationPaymentInfo) === null || _d === void 0 ? void 0 : _d.amount,
95
+ coverFees: this.coverFees,
96
+ feeCovered: (_e = this.donationPaymentInfo) === null || _e === void 0 ? void 0 : _e.feeAmountCovered,
97
+ },
98
+ }));
99
+ }
100
+ /* captures form changes */
101
+ captureAmountChanges(newAmount) {
102
+ if (!this.donationPaymentInfo && this.plan) {
103
+ this.donationPaymentInfo = new DonationPaymentInfo({
104
+ donationType: DonationType.Monthly,
105
+ amount: 0,
106
+ coverFees: true,
107
+ });
108
+ return;
109
+ }
110
+ let newPlan;
111
+ if (newAmount) {
112
+ newPlan = new DonationPaymentInfo({
113
+ donationType: DonationType.Monthly,
114
+ amount: newAmount,
115
+ coverFees: true,
116
+ });
117
+ }
118
+ else {
119
+ const amount = this.donationPaymentInfo
120
+ ? this.donationPaymentInfo.amount
121
+ : this.plan.amount;
122
+ newPlan = new DonationPaymentInfo({
123
+ donationType: DonationType.Monthly,
124
+ amount,
125
+ coverFees: true,
126
+ });
127
+ }
128
+ this.donationPaymentInfo = newPlan;
129
+ }
130
+ closeForm() {
131
+ this.clearInputField();
132
+ this.clearStatusMessaging();
133
+ this.currentlyEditing = false;
134
+ this.coverFees = false;
135
+ this.errorMessage = '';
136
+ }
137
+ clearInputField() {
138
+ const input = this.form.querySelector('input[name="amount"]');
139
+ input.value = '';
140
+ this.newAmount = 0;
141
+ this.donationPaymentInfo = undefined;
142
+ }
143
+ async clearStatusMessaging() {
144
+ this.errorMessage = '';
145
+ this.updateMessage = '';
146
+ this.updateStatus = '';
147
+ await this.updateComplete;
148
+ }
149
+ /* DISPLAY */
150
+ totalAmountWithFees() {
151
+ if (this.newAmount === 0) {
152
+ return 0;
153
+ }
154
+ return DonationPaymentInfo.calculateTotal(this.newAmount, this.coverFees);
155
+ }
156
+ get coveredFeesText() {
157
+ var _a;
158
+ return `I'll generously add $${(_a = this.donationPaymentInfo) === null || _a === void 0 ? void 0 : _a.feeAmountCovered} to cover fees.`;
159
+ }
160
+ get editAmountForm() {
161
+ var _a;
162
+ return html `
163
+ <section>
164
+ <form id="edit-plan-amount">
165
+ <p>Current donation amount: $${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.amount}</p>
166
+ <div>
167
+ $
168
+ <input
169
+ type="number"
170
+ id="amount"
171
+ name="amount"
172
+ required="true"
173
+ @focus=${() => this.clearStatusMessaging()}
174
+ @input=${(e) => {
175
+ const newAmount = Number(e.target.value);
176
+ this.captureAmountChanges(newAmount);
177
+ this.newAmount = newAmount;
178
+ }}
179
+ />
180
+ / month
181
+ </div>
182
+ <div>
183
+ <div class="checkbox-option-container">
184
+ <input
185
+ type="checkbox"
186
+ id="cover-fees"
187
+ tabindex="0"
188
+ @change=${(e) => {
189
+ const input = e.target;
190
+ const coverFees = input.checked;
191
+ this.coverFees = coverFees;
192
+ this.captureAmountChanges();
193
+ }}
194
+ />
195
+ <label for="cover-fees">${this.coveredFeesText}</label>
196
+ </div>
197
+ <p>Total: USD $${this.totalAmountWithFees()}</p>
198
+ <div class="cta-container">
199
+ <ia-button
200
+ class="ia-button secondary"
201
+ .clickHandler=${(e) => {
202
+ e.preventDefault();
203
+ this.closeForm();
204
+ }}
205
+ >
206
+ Cancel
207
+ </ia-button>
208
+ <ia-button
209
+ id="update-amount"
210
+ class="ia-button primary"
211
+ type="submit"
212
+ .clickHandler=${async (e, iaButton) => {
213
+ var _a;
214
+ this.clearStatusMessaging();
215
+ if (!this.newAmount) {
216
+ this.errorMessage = 'Please enter a new amount';
217
+ return;
218
+ }
219
+ // eslint-disable-next-line no-param-reassign
220
+ iaButton.isDisabled = true;
221
+ await iaButton.updateComplete;
222
+ // check if request is in range
223
+ const input = this.form.querySelector('input[name="amount"]');
224
+ const requestedAmount = (_a = Number(input.value)) !== null && _a !== void 0 ? _a : 0;
225
+ const amountTooLow = requestedAmount < 1;
226
+ const amountTooHigh = requestedAmount >= 9999;
227
+ if (amountTooLow) {
228
+ this.errorMessage = 'Please enter a valid amount';
229
+ }
230
+ if (amountTooHigh) {
231
+ this.errorMessage =
232
+ 'Amount must be less than $9,999. Would you like to donate more? Please contact us at donations@archive.org';
233
+ }
234
+ if (amountTooHigh || amountTooLow) {
235
+ // eslint-disable-next-line no-param-reassign
236
+ iaButton.isDisabled = false;
237
+ await iaButton.updateComplete;
238
+ return;
239
+ }
240
+ this.requestAmountUpdate(e);
241
+ }}
242
+ >
243
+ Update
244
+ </ia-button>
245
+ <ia-mgc-update-status .status=${this.updateStatus}
246
+ >${this.updateMessage}</ia-mgc-update-status
247
+ >
248
+ </div>
249
+ </div>
250
+ <p class="error">${this.errorMessage}</p>
251
+ </form>
252
+ </section>
253
+ `;
254
+ }
255
+ };
256
+ MGCEditPlanAmount.styles = css `
257
+ input#amount {
258
+ width: 50px;
259
+ }
260
+
261
+ .cta-container {
262
+ display: flex;
263
+ flex-direction: row;
264
+ flex-wrap: wrap;
265
+ align-content: center;
266
+ justify-content: flex-start;
267
+ align-items: center;
268
+ gap: 10px;
269
+ }
270
+
271
+ p.error {
272
+ color: var(--mgc-warning-color-dark, #bb0505);
273
+ }
274
+
275
+ ia-mgc-update-status {
276
+ display: inline-block;
277
+ margin-left: 1rem;
278
+ }
279
+
280
+ .checkbox-option-container {
281
+ margin: 10px 0;
282
+ display: flex;
283
+ }
284
+ `;
285
+ __decorate([
286
+ property({ type: Object })
287
+ ], MGCEditPlanAmount.prototype, "plan", void 0);
288
+ __decorate([
289
+ property({ type: Object })
290
+ ], MGCEditPlanAmount.prototype, "donationPaymentInfo", void 0);
291
+ __decorate([
292
+ property({ type: Number })
293
+ ], MGCEditPlanAmount.prototype, "newAmount", void 0);
294
+ __decorate([
295
+ property({ type: Boolean, reflect: true })
296
+ ], MGCEditPlanAmount.prototype, "currentlyEditing", void 0);
297
+ __decorate([
298
+ property({ type: Boolean })
299
+ ], MGCEditPlanAmount.prototype, "coverFees", void 0);
300
+ __decorate([
301
+ property({ type: String })
302
+ ], MGCEditPlanAmount.prototype, "updateMessage", void 0);
303
+ __decorate([
304
+ property({ type: String })
305
+ ], MGCEditPlanAmount.prototype, "errorMessage", void 0);
306
+ __decorate([
307
+ property({ type: String })
308
+ ], MGCEditPlanAmount.prototype, "updateStatus", void 0);
309
+ __decorate([
310
+ query('form')
311
+ ], MGCEditPlanAmount.prototype, "form", void 0);
312
+ MGCEditPlanAmount = __decorate([
313
+ customElement('ia-mgc-edit-plan-amount')
314
+ ], MGCEditPlanAmount);
315
+ export { MGCEditPlanAmount };
316
+ //# sourceMappingURL=amount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/form-sections/amount.ts"],"names":[],"mappings":";AA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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"]}
@@ -29,7 +29,7 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
29
29
  }
30
30
  return html `
31
31
  <ia-button
32
- class="clear-container"
32
+ class="clear-container slim"
33
33
  .clickHandler=${(e, iaButton) => {
34
34
  // eslint-disable-next-line no-param-reassign
35
35
  iaButton.isDisabled = true;
@@ -104,6 +104,9 @@ let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
104
104
  }
105
105
  };
106
106
  IauxMgcCancelPlan.styles = css `
107
+ :host {
108
+ --formSectionTitleFontSize: 1.4rem;
109
+ }
107
110
  .warning > * {
108
111
  margin: 5px 0;
109
112
  }
@@ -141,7 +144,8 @@ IauxMgcCancelPlan.styles = css `
141
144
  }
142
145
 
143
146
  .checkbox-option-container {
144
- margin-bottom: 5px;
147
+ display: flex;
148
+ margin: 10px 0;
145
149
  }
146
150
  `;
147
151
  __decorate([
@@ -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;AAInE,OAAO,oFAAoF,CAAC;AAE5F,OAAO,wCAAwC,CAAC;AAGhD,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,UAAU;IAAjD;;QAG8C,0BAAqB,GAAG,IAAI,CAAC;QAE7B,yBAAoB,GAAG,KAAK,CAAC;IA+I3E,CAAC;IA3IC,OAAO,CAAC,OAAuB;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACvB,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;SACxC;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,CAAQ;QAC3B,CAAC,CAAC,cAAc,E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CAAC,CAAC,MAA2B;iBACzD,OAAO,CAAC;YACX,MAAM,IAAI,CAAC,cAAc,CAAC;QAC5B,CAAC;uBACU,WAAW,IAAI,CAAC,MAAM,EAAE;;;;;wBAKvB,IAAI,CAAC,qBAAqB;eACnC,UAAU,IAAI,CAAC,MAAM,EAAE;;0BAEZ,CAAC,CAAQ,EAAE,QAAoB,EAAE,EAAE;YACjD,6CAA6C;YAC7C,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;;;;KAIN,CAAC;IACJ,CAAC;CA2CF,CAAA;AAzCQ,wBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwClB,CAAC;AAlJ0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAoB;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,CAoJ7B;SApJY,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 { IauxButton } from '../presentational/ia-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-button\n class=\"clear-container\"\n .clickHandler=${(e: CustomEvent, iaButton: IauxButton) => {\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-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-button class='text exit-cancel' @click=${() => {\n this.initialCancelRequest = false;\n this.patronWantsToKeepPlan = true;\n }}>X</ia-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-button\n class=\"cancel\"\n .isDisabled=${this.patronWantsToKeepPlan}\n id=${`submit-${this.formId}`}\n type=\"submit\"\n .clickHandler=${(e: Event, iaButton: IauxButton) => {\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-button>\n </form>\n </section>\n `;\n }\n\n static styles = css`\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-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-button {\n --button-height: auto;\n }\n\n ia-button > * {\n text-align: left;\n text-wrap: wrap;\n }\n\n h3 {\n position: relative;\n }\n\n .checkbox-option-container {\n margin-bottom: 5px;\n }\n `;\n}\n"]}
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;AAInE,OAAO,oFAAoF,CAAC;AAE5F,OAAO,wCAAwC,CAAC;AAGhD,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,UAAU;IAAjD;;QAG8C,0BAAqB,GAAG,IAAI,CAAC;QAE7B,yBAAoB,GAAG,KAAK,CAAC;IAmJ3E,CAAC;IA/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';\nimport type { MonthlyPlan } from '../models/plan';\n\nimport type { IauxButton } from '../presentational/ia-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-button\n class=\"clear-container slim\"\n .clickHandler=${(e: Event, iaButton: IauxButton) => {\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-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-button class='text exit-cancel' @click=${() => {\n this.initialCancelRequest = false;\n this.patronWantsToKeepPlan = true;\n }}>X</ia-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-button\n class=\"cancel\"\n .isDisabled=${this.patronWantsToKeepPlan}\n id=${`submit-${this.formId}`}\n type=\"submit\"\n .clickHandler=${(e: Event, iaButton: IauxButton) => {\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-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-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-button {\n --button-height: auto;\n }\n\n ia-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"]}
@@ -34,6 +34,7 @@ export declare class MonthlyPlan {
34
34
  get id(): string;
35
35
  get currencySymbol(): string;
36
36
  get amount(): number;
37
+ setAmount(newAmount: number): void;
37
38
  get startDate(): string;
38
39
  get nextBillingDate(): string;
39
40
  get hasBeenCancelled(): boolean;
@@ -15,6 +15,10 @@ export class MonthlyPlan {
15
15
  get amount() {
16
16
  return this.plan.amount;
17
17
  }
18
+ setAmount(newAmount) {
19
+ this.plan.oldAmount = this.plan.amount;
20
+ this.plan.amount = newAmount;
21
+ }
18
22
  get startDate() {
19
23
  const date = new Date(this.plan.start_date);
20
24
  return date.toLocaleDateString();
@@ -1 +1 @@
1
- {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../src/models/plan.ts"],"names":[],"mappings":"AA8BA,MAAM,OAAO,WAAW;IAOtB,YAAY,IAAU;;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAA,IAAI,CAAC,QAAQ,mCAAI,KAAK,CAAC,CAAC,cAAc;IACxD,CAAC;IAED,IAAI,EAAE;QACJ,yBAAyB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,IAAI,SAAS;QACX,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,eAAe;QACjB,MAAM,eAAe,GAAG,IAAI,IAAI,CAC9B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAClC,CAAC,kBAAkB,CAAC,SAAS,EAAE;YAC9B,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,OAAO;YACd,GAAG,EAAE,SAAS;SACf,CAAC,CAAC;QAEH,OAAO,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC;IACxC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;IAwBI","sourcesContent":["type BtData = {\n billingDayOfMonth: number;\n nextBillingDate: {\n date: string;\n timezone_type: number;\n timezone: string;\n };\n status: string; // active, inactive\n paymentMethodType: string; // cc, paypal, venmo, etc\n last4: string | null;\n cardType: string | null;\n expirationMonth: string | null;\n expirationYear: string | null;\n paypalEmail?: string;\n venmoUsername?: string;\n};\n\ntype Plan = {\n token: string;\n amount: number;\n currency: string;\n start_date: string; // UTC\n is_test: boolean;\n btdata: BtData;\n oldAmount?: number;\n oldDate?: string;\n oldPaymentMethod?: string;\n isCancelled?: boolean;\n};\n\nexport class MonthlyPlan {\n plan: Plan;\n\n currency: string;\n\n payment: BtData;\n\n constructor(plan: Plan) {\n this.plan = plan;\n this.payment = plan.btdata;\n this.currency = plan.currency ?? 'USD'; // not in data\n }\n\n get id(): string {\n // use token as unique id\n return this.plan.token;\n }\n\n get currencySymbol(): string {\n return this.currency === 'USD' ? '$' : '';\n }\n\n get amount(): number {\n return this.plan.amount;\n }\n\n get startDate(): string {\n const date = new Date(this.plan.start_date);\n return date.toLocaleDateString();\n }\n\n get nextBillingDate(): string {\n const nextBillingDate = new Date(\n this.payment.nextBillingDate.date\n ).toLocaleDateString(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n\n return nextBillingDate ?? 'not found';\n }\n\n get hasBeenCancelled(): boolean {\n return this.plan.isCancelled === true;\n }\n\n get isTest(): boolean {\n return this.plan.is_test;\n }\n\n cancelPlan(): void {\n this.plan.isCancelled = true;\n }\n}\n\n/*\n\n{\n \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtYWlsc3luYyIsImlhdCI6MTczODYxNTY3NS41ODA4MTcsIm5iZiI6MTczODYxNTYxNS41ODA4MTcsImV4cCI6MTczODYxNjI3NS41ODA4MTcsImtleSI6eyJwaWQiOiJkd2NrN20iLCJjaWQiOjgwMzUzOCwiYW1vdW50Ijo1LCJwYXltZW50TWV0aG9kVG9rZW4iOiJxMXllYndoaiIsImN1c3RvbWVySWQiOiI4NTQ2MTk4MzUifSwidXNlciI6IkBpc2EtYXQtdGhlLWFyY2hpdmUifQ.TYlkU1ZZLHmj2ahrkTV7JGLmpCPN4BcOeDFPiXVj0pM\",\n \"amount\": 5,\n \"currency\": \"USD\",\n \"start_date\": \"2022-12-09 00:00:00\",\n \"contribution_status_id\": 5,\n \"is_test\": true,\n \"btdata\": {\n \"billingDayOfMonth\": 9,\n \"nextBillingDate\": {\n \"date\": \"2025-02-09 00:00:00.000000\",\n \"timezone_type\": 3,\n \"timezone\": \"UTC\"\n },\n \"status\": \"Active\",\n \"paymentMethodType\": \"creditCard\",\n \"last4\": \"1111\",\n \"cardType\": \"Visa\",\n \"expirationMonth\": \"12\",\n \"expirationYear\": \"2023\"\n }\n}\n */\n"]}
1
+ {"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../src/models/plan.ts"],"names":[],"mappings":"AA8BA,MAAM,OAAO,WAAW;IAOtB,YAAY,IAAU;;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,MAAA,IAAI,CAAC,QAAQ,mCAAI,KAAK,CAAC,CAAC,cAAc;IACxD,CAAC;IAED,IAAI,EAAE;QACJ,yBAAyB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,SAAS,CAAC,SAAiB;QACzB,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,SAAS;QACX,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,eAAe;QACjB,MAAM,eAAe,GAAG,IAAI,IAAI,CAC9B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAClC,CAAC,kBAAkB,CAAC,SAAS,EAAE;YAC9B,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,OAAO;YACd,GAAG,EAAE,SAAS;SACf,CAAC,CAAC;QAEH,OAAO,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,WAAW,CAAC;IACxC,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC;IACxC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC/B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;IAwBI","sourcesContent":["type BtData = {\n billingDayOfMonth: number;\n nextBillingDate: {\n date: string;\n timezone_type: number;\n timezone: string;\n };\n status: string; // active, inactive\n paymentMethodType: string; // cc, paypal, venmo, etc\n last4: string | null;\n cardType: string | null;\n expirationMonth: string | null;\n expirationYear: string | null;\n paypalEmail?: string;\n venmoUsername?: string;\n};\n\ntype Plan = {\n token: string;\n amount: number;\n currency: string;\n start_date: string; // UTC\n is_test: boolean;\n btdata: BtData;\n oldAmount?: number;\n oldDate?: string;\n oldPaymentMethod?: string;\n isCancelled?: boolean;\n};\n\nexport class MonthlyPlan {\n plan: Plan;\n\n currency: string;\n\n payment: BtData;\n\n constructor(plan: Plan) {\n this.plan = plan;\n this.payment = plan.btdata;\n this.currency = plan.currency ?? 'USD'; // not in data\n }\n\n get id(): string {\n // use token as unique id\n return this.plan.token;\n }\n\n get currencySymbol(): string {\n return this.currency === 'USD' ? '$' : '';\n }\n\n get amount(): number {\n return this.plan.amount;\n }\n\n setAmount(newAmount: number) {\n this.plan.oldAmount = this.plan.amount;\n this.plan.amount = newAmount;\n }\n\n get startDate(): string {\n const date = new Date(this.plan.start_date);\n return date.toLocaleDateString();\n }\n\n get nextBillingDate(): string {\n const nextBillingDate = new Date(\n this.payment.nextBillingDate.date\n ).toLocaleDateString(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n });\n\n return nextBillingDate ?? 'not found';\n }\n\n get hasBeenCancelled(): boolean {\n return this.plan.isCancelled === true;\n }\n\n get isTest(): boolean {\n return this.plan.is_test;\n }\n\n cancelPlan(): void {\n this.plan.isCancelled = true;\n }\n}\n\n/*\n\n{\n \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJtYWlsc3luYyIsImlhdCI6MTczODYxNTY3NS41ODA4MTcsIm5iZiI6MTczODYxNTYxNS41ODA4MTcsImV4cCI6MTczODYxNjI3NS41ODA4MTcsImtleSI6eyJwaWQiOiJkd2NrN20iLCJjaWQiOjgwMzUzOCwiYW1vdW50Ijo1LCJwYXltZW50TWV0aG9kVG9rZW4iOiJxMXllYndoaiIsImN1c3RvbWVySWQiOiI4NTQ2MTk4MzUifSwidXNlciI6IkBpc2EtYXQtdGhlLWFyY2hpdmUifQ.TYlkU1ZZLHmj2ahrkTV7JGLmpCPN4BcOeDFPiXVj0pM\",\n \"amount\": 5,\n \"currency\": \"USD\",\n \"start_date\": \"2022-12-09 00:00:00\",\n \"contribution_status_id\": 5,\n \"is_test\": true,\n \"btdata\": {\n \"billingDayOfMonth\": 9,\n \"nextBillingDate\": {\n \"date\": \"2025-02-09 00:00:00.000000\",\n \"timezone_type\": 3,\n \"timezone\": \"UTC\"\n },\n \"status\": \"Active\",\n \"paymentMethodType\": \"creditCard\",\n \"last4\": \"1111\",\n \"cardType\": \"Visa\",\n \"expirationMonth\": \"12\",\n \"expirationYear\": \"2023\"\n }\n}\n */\n"]}
@@ -7,11 +7,12 @@ import type { IauxMgcReceipts } from './receipts';
7
7
  import './presentational/ia-button';
8
8
  import type { MonthlyPlan } from './models/plan';
9
9
  import './edit-plan-form';
10
+ import type { IauxEditPlanForm } from './edit-plan-form';
10
11
  export declare type APlanUpdate = {
11
12
  plan?: MonthlyPlan;
12
13
  donationId?: string;
13
14
  status: 'success' | 'fail';
14
- action: 'receiptSent' | 'cancel';
15
+ action: 'receiptSent' | 'cancel' | 'amountUpdate';
15
16
  message: string;
16
17
  };
17
18
  export declare class MonthlyGivingCircle extends LitElement {
@@ -21,9 +22,11 @@ export declare class MonthlyGivingCircle extends LitElement {
21
22
  plans: never[];
22
23
  editingThisPlan?: MonthlyPlan;
23
24
  viewToDisplay: 'welcome' | 'receipts' | 'plans' | 'editPlan';
25
+ canEdit: boolean;
24
26
  protected createRenderRoot(): this;
25
27
  updated(changed: PropertyValues): void;
26
28
  get receiptListElement(): IauxMgcReceipts;
29
+ get editFormElement(): IauxEditPlanForm;
27
30
  updateReceived(update: APlanUpdate): void;
28
31
  protected render(): TemplateResult<1>;
29
32
  get sectionTitle(): TemplateResult;