@internetarchive/donation-monthly-portal 3.0.0 → 4.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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/edit-plan-form.d.ts +8 -0
- package/dist/src/edit-plan-form.js +33 -0
- package/dist/src/edit-plan-form.js.map +1 -0
- package/dist/src/form-sections/cancel.d.ts +16 -0
- package/dist/src/form-sections/cancel.js +163 -0
- package/dist/src/form-sections/cancel.js.map +1 -0
- package/dist/src/models/plan.d.ts +2 -0
- package/dist/src/models/plan.js +6 -0
- package/dist/src/models/plan.js.map +1 -1
- package/dist/src/models/receipt.d.ts +1 -0
- package/dist/src/models/receipt.js.map +1 -1
- package/dist/src/monthly-giving-circle.d.ts +13 -8
- package/dist/src/monthly-giving-circle.js +117 -59
- package/dist/src/monthly-giving-circle.js.map +1 -1
- package/dist/src/plans.js +22 -7
- package/dist/src/plans.js.map +1 -1
- package/dist/src/presentational/ia-button.d.ts +1 -1
- package/dist/src/presentational/ia-button.js +22 -5
- package/dist/src/presentational/ia-button.js.map +1 -1
- package/dist/test/edit-plan-form.test.d.ts +1 -0
- package/dist/test/edit-plan-form.test.js +39 -0
- package/dist/test/edit-plan-form.test.js.map +1 -0
- package/dist/test/monthly-giving-circle.test.js +17 -2
- package/dist/test/monthly-giving-circle.test.js.map +1 -1
- package/dist/test/receipt-email-request-flow.test.js +17 -8
- package/dist/test/receipt-email-request-flow.test.js.map +1 -1
- package/package.json +3 -1
- package/src/edit-plan-form.ts +28 -0
- package/src/form-sections/cancel.ts +166 -0
- package/src/models/plan.ts +8 -0
- package/src/models/receipt.ts +1 -0
- package/src/monthly-giving-circle.ts +144 -71
- package/src/plans.ts +26 -7
- package/src/presentational/ia-button.ts +27 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { MonthlyGivingCircle } from './src/monthly-giving-circle';
|
|
2
|
-
export type {
|
|
2
|
+
export type { APlanUpdate } from './src/monthly-giving-circle';
|
|
3
3
|
export { Receipt } from './src/models/receipt';
|
|
4
4
|
export { MonthlyPlan } from './src/models/plan';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { MonthlyGivingCircle } from './src/monthly-giving-circle';\nexport type {
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export { MonthlyGivingCircle } from './src/monthly-giving-circle';\nexport type { APlanUpdate } from './src/monthly-giving-circle';\nexport { Receipt } from './src/models/receipt';\nexport { MonthlyPlan } from './src/models/plan';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { MonthlyPlan } from './models/plan';
|
|
3
|
+
import './form-sections/cancel';
|
|
4
|
+
export declare class IauxEditPlanForm extends LitElement {
|
|
5
|
+
plan?: MonthlyPlan;
|
|
6
|
+
cancelPlanHandler?: (plan: MonthlyPlan) => void;
|
|
7
|
+
render(): import("lit").TemplateResult<1>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import './form-sections/cancel';
|
|
5
|
+
let IauxEditPlanForm = class IauxEditPlanForm extends LitElement {
|
|
6
|
+
render() {
|
|
7
|
+
return html `
|
|
8
|
+
<section class="mgc-edit-plan">
|
|
9
|
+
<hr />
|
|
10
|
+
<ia-mgc-cancel-plan
|
|
11
|
+
.plan=${this.plan}
|
|
12
|
+
@cancelPlan=${() => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (this.plan) {
|
|
15
|
+
(_a = this.cancelPlanHandler) === null || _a === void 0 ? void 0 : _a.call(this, this.plan);
|
|
16
|
+
}
|
|
17
|
+
}}
|
|
18
|
+
></ia-mgc-cancel-plan>
|
|
19
|
+
</section>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
property({ type: Object })
|
|
25
|
+
], IauxEditPlanForm.prototype, "plan", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
property({ type: Object })
|
|
28
|
+
], IauxEditPlanForm.prototype, "cancelPlanHandler", void 0);
|
|
29
|
+
IauxEditPlanForm = __decorate([
|
|
30
|
+
customElement('ia-mgc-edit-plan')
|
|
31
|
+
], IauxEditPlanForm);
|
|
32
|
+
export { IauxEditPlanForm };
|
|
33
|
+
//# sourceMappingURL=edit-plan-form.js.map
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LitElement, TemplateResult, PropertyValues, nothing } from 'lit';
|
|
2
|
+
import type { MonthlyPlan } from '../models/plan';
|
|
3
|
+
import '@internetarchive/donation-form/dist/src/form-elements/contact-form/contact-form.js';
|
|
4
|
+
import '@internetarchive/donation-form-section';
|
|
5
|
+
export declare class IauxMgcCancelPlan extends LitElement {
|
|
6
|
+
plan?: MonthlyPlan;
|
|
7
|
+
patronWantsToKeepPlan: boolean;
|
|
8
|
+
initialCancelRequest: boolean;
|
|
9
|
+
form: HTMLFormElement;
|
|
10
|
+
updated(changed: PropertyValues): void;
|
|
11
|
+
cancelThisPlan(e: Event): Promise<void>;
|
|
12
|
+
get formId(): string;
|
|
13
|
+
protected render(): typeof nothing | TemplateResult<2 | 1>;
|
|
14
|
+
get confirmCancelation(): TemplateResult | typeof nothing;
|
|
15
|
+
static styles: import("lit").CSSResult;
|
|
16
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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/dist/src/form-elements/contact-form/contact-form.js';
|
|
5
|
+
import '@internetarchive/donation-form-section';
|
|
6
|
+
let IauxMgcCancelPlan = class IauxMgcCancelPlan extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.patronWantsToKeepPlan = true;
|
|
10
|
+
this.initialCancelRequest = false;
|
|
11
|
+
}
|
|
12
|
+
updated(changed) {
|
|
13
|
+
if (changed.has('plan')) {
|
|
14
|
+
console.log('plan updated', this.plan);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async cancelThisPlan(e) {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
this.patronWantsToKeepPlan = false;
|
|
20
|
+
this.dispatchEvent(new Event('cancelPlan'));
|
|
21
|
+
}
|
|
22
|
+
get formId() {
|
|
23
|
+
var _a;
|
|
24
|
+
return `cancel-donation-form-${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.id}`;
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
if (this.initialCancelRequest) {
|
|
28
|
+
return this.confirmCancelation;
|
|
29
|
+
}
|
|
30
|
+
return html `
|
|
31
|
+
<ia-button
|
|
32
|
+
class="clear-container"
|
|
33
|
+
.clickHandler=${(e, iaButton) => {
|
|
34
|
+
// eslint-disable-next-line no-param-reassign
|
|
35
|
+
iaButton.isDisabled = true;
|
|
36
|
+
if (this.initialCancelRequest) {
|
|
37
|
+
this.initialCancelRequest = false;
|
|
38
|
+
this.patronWantsToKeepPlan = true;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.initialCancelRequest = true;
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<donation-form-section
|
|
45
|
+
badgemode="hidebadge"
|
|
46
|
+
headline="Cancel recurring donation (requires confirmation)"
|
|
47
|
+
>
|
|
48
|
+
<div class="warning">
|
|
49
|
+
<p>
|
|
50
|
+
You can also pause your recurring donation by setting the next
|
|
51
|
+
donation date up to 12 months in the future.
|
|
52
|
+
</p>
|
|
53
|
+
<p>Let's cancel my donation</p>
|
|
54
|
+
</div>
|
|
55
|
+
</donation-form-section>
|
|
56
|
+
</ia-button>
|
|
57
|
+
|
|
58
|
+
${this.initialCancelRequest ? this.confirmCancelation : nothing}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
get confirmCancelation() {
|
|
62
|
+
return html `
|
|
63
|
+
<section class="cancel-donation">
|
|
64
|
+
<donation-form-section badgemode="hidebadge" headline="Cancel recurring donation">
|
|
65
|
+
|
|
66
|
+
<ia-button class='text exit-cancel' @click=${() => {
|
|
67
|
+
this.initialCancelRequest = false;
|
|
68
|
+
this.patronWantsToKeepPlan = true;
|
|
69
|
+
}}>X</ia-button>
|
|
70
|
+
|
|
71
|
+
<p>Canceling ends your monthly recurring donation to the Internet Archive, effective immediately. You will not be charged moving forward.</p>
|
|
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>
|
|
73
|
+
<p>If you have any questions regarding donations, contact us at <a href="mailto:donations@archive.org">donations@archive.org</a></p>
|
|
74
|
+
|
|
75
|
+
<form id=${this.formId} @submit=${(e) => this.cancelThisPlan(e)}>
|
|
76
|
+
<div class="checkbox-option-container">
|
|
77
|
+
<input
|
|
78
|
+
id=${`confirm-${this.formId}`}
|
|
79
|
+
type="checkbox"
|
|
80
|
+
required
|
|
81
|
+
@change=${async (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
this.patronWantsToKeepPlan = !e.target
|
|
84
|
+
.checked;
|
|
85
|
+
await this.updateComplete;
|
|
86
|
+
}}>
|
|
87
|
+
<label for=${`confirm-${this.formId}`}><b>I'm sure I want to cancel my subscription</b></label>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<ia-button
|
|
91
|
+
class="cancel"
|
|
92
|
+
.isDisabled=${this.patronWantsToKeepPlan}
|
|
93
|
+
id=${`submit-${this.formId}`}
|
|
94
|
+
type="submit"
|
|
95
|
+
.clickHandler=${(e, iaButton) => {
|
|
96
|
+
// eslint-disable-next-line no-param-reassign
|
|
97
|
+
iaButton.isDisabled = true;
|
|
98
|
+
this.cancelThisPlan(e);
|
|
99
|
+
}}
|
|
100
|
+
>I'm sure I want to cancel my recurring donation.</ia-button>
|
|
101
|
+
</form>
|
|
102
|
+
</section>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
IauxMgcCancelPlan.styles = css `
|
|
107
|
+
.warning > * {
|
|
108
|
+
margin: 5px 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.cancel-donation {
|
|
112
|
+
display: block;
|
|
113
|
+
border: 2px solid #d9534f;
|
|
114
|
+
background-color: #ffeeee;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.cancel-donation > * {
|
|
118
|
+
padding: 5px;
|
|
119
|
+
position: relative;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
ia-button.exit-cancel {
|
|
123
|
+
--button-border: 1px solid;
|
|
124
|
+
--button-border-radius: 50%;
|
|
125
|
+
position: absolute;
|
|
126
|
+
top: -5px;
|
|
127
|
+
right: -10px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
ia-button {
|
|
131
|
+
--button-height: auto;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
ia-button > * {
|
|
135
|
+
text-align: left;
|
|
136
|
+
text-wrap: wrap;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
h3 {
|
|
140
|
+
position: relative;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.checkbox-option-container {
|
|
144
|
+
margin-bottom: 5px;
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
__decorate([
|
|
148
|
+
property({ type: Object })
|
|
149
|
+
], IauxMgcCancelPlan.prototype, "plan", void 0);
|
|
150
|
+
__decorate([
|
|
151
|
+
property({ type: Boolean, reflect: true })
|
|
152
|
+
], IauxMgcCancelPlan.prototype, "patronWantsToKeepPlan", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property({ type: Boolean, reflect: true })
|
|
155
|
+
], IauxMgcCancelPlan.prototype, "initialCancelRequest", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
query('form')
|
|
158
|
+
], IauxMgcCancelPlan.prototype, "form", void 0);
|
|
159
|
+
IauxMgcCancelPlan = __decorate([
|
|
160
|
+
customElement('ia-mgc-cancel-plan')
|
|
161
|
+
], IauxMgcCancelPlan);
|
|
162
|
+
export { IauxMgcCancelPlan };
|
|
163
|
+
//# sourceMappingURL=cancel.js.map
|
|
@@ -0,0 +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,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B,KAAK,EAAE,CAAQ,EAAE,EAAE;YAC3B,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,qBAAqB,GAAG,CAAE,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"]}
|
package/dist/src/models/plan.js
CHANGED
|
@@ -27,9 +27,15 @@ export class MonthlyPlan {
|
|
|
27
27
|
});
|
|
28
28
|
return nextBillingDate !== null && nextBillingDate !== void 0 ? nextBillingDate : 'not found';
|
|
29
29
|
}
|
|
30
|
+
get hasBeenCancelled() {
|
|
31
|
+
return this.plan.isCancelled === true;
|
|
32
|
+
}
|
|
30
33
|
get isTest() {
|
|
31
34
|
return this.plan.is_test;
|
|
32
35
|
}
|
|
36
|
+
cancelPlan() {
|
|
37
|
+
this.plan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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 isTest(): boolean {\n return this.plan.is_test;\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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"receipt.js","sourceRoot":"","sources":["../../../src/models/receipt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"receipt.js","sourceRoot":"","sources":["../../../src/models/receipt.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,OAAO;IAGlB,YAAY,OAAiB;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,eAAe;;QACjB,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,YAAY,mCAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACnE,MAAM,YAAY,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,mCAAI,gBAAgB,CAAC;QAC/D,IAAI,KAAK,EAAE;YACT,OAAO,GAAG,YAAY,IAAI,IAAI,CAAC,cAAc,GAAG,KAAK,EAAE,CAAC;SACzD;QACD,OAAO,wDAAwD,CAAC;IAClE,CAAC;IAED,IAAI,MAAM;;QACR,OAAO,CACL,MAAA,MAAA,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,mCAC9B,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,mCAC5B,wDAAwD,CACzD,CAAC;IACJ,CAAC;IAED,IAAI,MAAM;;QACR,OAAO,MAAA,IAAI,CAAC,OAAO,CAAC,MAAM,mCAAI,KAAK,CAAC;IACtC,CAAC;IAED,IAAI,EAAE;;QACJ,OAAO,MAAA,IAAI,CAAC,OAAO,CAAC,KAAK,mCAAI,gBAAgB,CAAC;IAChD,CAAC;IAED,IAAI,IAAI;;QACN,OAAO,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,mCAAI,eAAe,CAAC;IAC9C,CAAC;IAED,IAAI,cAAc;QAChB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE;YACnC,OAAO,GAAG,CAAC;SACZ;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["type AReceipt = {\n currency: string;\n net_amount: number;\n total_amount: number;\n fee_amount: number;\n receive_date?: Date;\n date: string;\n isTest: boolean;\n token: string;\n};\nexport class Receipt {\n receipt: AReceipt;\n\n constructor(receipt: AReceipt) {\n this.receipt = receipt;\n }\n\n get amountFormatted(): string {\n const value = this.receipt.total_amount ?? this.receipt.net_amount;\n const currencyType = this.receipt.currency ?? 'CURR not found';\n if (value) {\n return `${currencyType} ${this.currencySymbol}${value}`;\n }\n return \"no amount found, can't find total_amount or net_amount\";\n }\n\n get amount(): string {\n return (\n `${this.receipt.total_amount}` ??\n `${this.receipt.net_amount}` ??\n \"no amount found, can't find total_amount or net_amount\"\n );\n }\n\n get isTest(): boolean {\n return this.receipt.isTest ?? false;\n }\n\n get id(): string {\n return this.receipt.token ?? 'no token found';\n }\n\n get date(): string {\n return this.receipt.date ?? 'no date found';\n }\n\n get currencySymbol(): string {\n if (this.receipt.currency === 'USD') {\n return '$';\n }\n\n return '';\n }\n}\n"]}
|
|
@@ -5,22 +5,27 @@ import './presentational/mgc-title';
|
|
|
5
5
|
import './receipts';
|
|
6
6
|
import type { IauxMgcReceipts } from './receipts';
|
|
7
7
|
import './presentational/ia-button';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import type { MonthlyPlan } from './models/plan';
|
|
9
|
+
import './edit-plan-form';
|
|
10
|
+
export declare type APlanUpdate = {
|
|
11
|
+
plan?: MonthlyPlan;
|
|
12
|
+
donationId?: string;
|
|
10
13
|
status: 'success' | 'fail';
|
|
11
|
-
|
|
14
|
+
action: 'receiptSent' | 'cancel';
|
|
15
|
+
message: string;
|
|
12
16
|
};
|
|
13
17
|
export declare class MonthlyGivingCircle extends LitElement {
|
|
14
18
|
patronName: string;
|
|
15
19
|
receipts: never[];
|
|
16
|
-
updates:
|
|
20
|
+
updates: APlanUpdate[];
|
|
17
21
|
plans: never[];
|
|
18
|
-
|
|
22
|
+
editingThisPlan?: MonthlyPlan;
|
|
23
|
+
viewToDisplay: 'welcome' | 'receipts' | 'plans' | 'editPlan';
|
|
19
24
|
protected createRenderRoot(): this;
|
|
20
25
|
updated(changed: PropertyValues): void;
|
|
21
26
|
get receiptListElement(): IauxMgcReceipts;
|
|
22
|
-
updateReceived(update:
|
|
23
|
-
get showReceiptsCTA(): TemplateResult;
|
|
24
|
-
get headerSection(): TemplateResult;
|
|
27
|
+
updateReceived(update: APlanUpdate): void;
|
|
25
28
|
protected render(): TemplateResult<1>;
|
|
29
|
+
get sectionTitle(): TemplateResult;
|
|
30
|
+
get nonEditView(): TemplateResult;
|
|
26
31
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-debugger */
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
|
-
import { LitElement, html
|
|
3
|
+
import { LitElement, html } from 'lit';
|
|
4
4
|
import { customElement, property } from 'lit/decorators.js';
|
|
5
5
|
import './welcome-message';
|
|
6
6
|
import './plans';
|
|
7
7
|
import './presentational/mgc-title';
|
|
8
8
|
import './receipts';
|
|
9
9
|
import './presentational/ia-button';
|
|
10
|
+
import './edit-plan-form';
|
|
10
11
|
let MonthlyGivingCircle = class MonthlyGivingCircle extends LitElement {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
@@ -27,91 +28,145 @@ let MonthlyGivingCircle = class MonthlyGivingCircle extends LitElement {
|
|
|
27
28
|
get receiptListElement() {
|
|
28
29
|
return this.querySelector('ia-mgc-receipts');
|
|
29
30
|
}
|
|
31
|
+
/* Update Callback */
|
|
30
32
|
updateReceived(update) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
// log update
|
|
35
|
+
this.updates.unshift(update);
|
|
36
|
+
const { plan, donationId = '' } = update;
|
|
37
|
+
const idToUse = (_a = plan === null || plan === void 0 ? void 0 : plan.id) !== null && _a !== void 0 ? _a : donationId;
|
|
38
|
+
const editingPlanIsUpdating = ((_b = this.editingThisPlan) === null || _b === void 0 ? void 0 : _b.id) === idToUse;
|
|
39
|
+
if (editingPlanIsUpdating) {
|
|
40
|
+
console.log('edit received, mismatch plans', {
|
|
41
|
+
planCurrentlyEditing: this.editingThisPlan,
|
|
42
|
+
planReceived: update.plan,
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (plan === null || plan === void 0 ? void 0 : plan.hasBeenCancelled) {
|
|
47
|
+
this.editingThisPlan = undefined;
|
|
48
|
+
this.viewToDisplay = 'plans';
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
31
51
|
this.receiptListElement.emailSent({
|
|
32
|
-
id:
|
|
52
|
+
id: idToUse,
|
|
33
53
|
emailStatus: update.status,
|
|
34
54
|
});
|
|
35
|
-
this.updates.unshift(update);
|
|
36
55
|
}
|
|
37
|
-
|
|
56
|
+
/* VIEWS */
|
|
57
|
+
render() {
|
|
58
|
+
const isEditingPlan = this.viewToDisplay === 'editPlan' && this.editingThisPlan;
|
|
38
59
|
return html `
|
|
60
|
+
${this.sectionTitle}
|
|
61
|
+
${isEditingPlan
|
|
62
|
+
? html `<ia-mgc-edit-plan
|
|
63
|
+
.plan=${this.editingThisPlan}
|
|
64
|
+
.cancelPlanHandler=${(plan) => {
|
|
65
|
+
console.log('cancelPlan', plan);
|
|
66
|
+
this.dispatchEvent(new CustomEvent('cancelPlan', {
|
|
67
|
+
detail: { plan },
|
|
68
|
+
}));
|
|
69
|
+
}}
|
|
70
|
+
></ia-mgc-edit-plan>`
|
|
71
|
+
: this.nonEditView}
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
get sectionTitle() {
|
|
75
|
+
let title = '';
|
|
76
|
+
let titleStyle = '';
|
|
77
|
+
let cta = html ``;
|
|
78
|
+
const receiptsCTA = html `
|
|
39
79
|
<ia-button
|
|
40
80
|
class="link slim"
|
|
41
|
-
.clickHandler=${() => {
|
|
81
|
+
.clickHandler=${async () => {
|
|
42
82
|
this.viewToDisplay = 'receipts';
|
|
83
|
+
await this.updateComplete;
|
|
43
84
|
this.dispatchEvent(new CustomEvent('ShowReceipts'));
|
|
44
85
|
}}
|
|
45
86
|
>
|
|
46
87
|
View recent donation history
|
|
47
88
|
</ia-button>
|
|
48
89
|
`;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
const displayReceiptsLink = this.receipts.length &&
|
|
91
|
+
(this.viewToDisplay === 'plans' || this.viewToDisplay === 'welcome');
|
|
92
|
+
switch (this.viewToDisplay) {
|
|
93
|
+
case 'receipts':
|
|
94
|
+
title = 'Recent donations';
|
|
95
|
+
titleStyle = 'default';
|
|
96
|
+
cta = html `<ia-button
|
|
97
|
+
class="link slim"
|
|
98
|
+
id="close-receipts"
|
|
99
|
+
.clickHandler=${async () => {
|
|
100
|
+
this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';
|
|
101
|
+
this.dispatchEvent(new CustomEvent('ShowWelcome'));
|
|
102
|
+
this.updates = [];
|
|
103
|
+
await this.updateComplete;
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
Back to account settings
|
|
107
|
+
</ia-button>`;
|
|
108
|
+
break;
|
|
109
|
+
case 'editPlan':
|
|
110
|
+
title = 'Edit plan';
|
|
111
|
+
titleStyle = 'default';
|
|
112
|
+
cta = html `<ia-button
|
|
113
|
+
class="primary"
|
|
114
|
+
id="close-edit-plan"
|
|
115
|
+
.clickHandler=${async () => {
|
|
116
|
+
this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';
|
|
117
|
+
this.dispatchEvent(new CustomEvent('ShowWelcome'));
|
|
118
|
+
this.updates = [];
|
|
119
|
+
await this.updateComplete;
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
Back to account settings
|
|
123
|
+
</ia-button>`;
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
title = 'Monthly Giving Circle';
|
|
127
|
+
titleStyle = 'heart';
|
|
128
|
+
if (displayReceiptsLink) {
|
|
129
|
+
cta = receiptsCTA;
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
81
132
|
}
|
|
82
133
|
return html `
|
|
83
|
-
<ia-mgc-title titleStyle
|
|
84
|
-
<span slot="title"
|
|
85
|
-
<span slot="action"
|
|
86
|
-
>${this.receipts.length ? this.showReceiptsCTA : nothing}</span
|
|
87
|
-
>
|
|
134
|
+
<ia-mgc-title titleStyle=${titleStyle}>
|
|
135
|
+
<span slot="title">${title}</span>
|
|
136
|
+
<span slot="action">${cta}</span>
|
|
88
137
|
</ia-mgc-title>
|
|
89
138
|
`;
|
|
90
139
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
.receipts=${this.receipts}
|
|
98
|
-
@EmailReceiptRequest=${(event) => {
|
|
140
|
+
get nonEditView() {
|
|
141
|
+
if (this.viewToDisplay === 'receipts') {
|
|
142
|
+
return html `
|
|
143
|
+
<ia-mgc-receipts
|
|
144
|
+
.receipts=${this.receipts}
|
|
145
|
+
@EmailReceiptRequest=${(event) => {
|
|
99
146
|
console.log('EmailReceiptRequest', event.detail);
|
|
100
147
|
this.dispatchEvent(new CustomEvent('EmailReceiptRequest', {
|
|
101
148
|
detail: { ...event.detail },
|
|
102
149
|
}));
|
|
103
150
|
}}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
: nothing}
|
|
110
|
-
${this.viewToDisplay === 'welcome'
|
|
151
|
+
></ia-mgc-receipts>
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
return html `
|
|
155
|
+
${this.viewToDisplay === 'plans' && this.plans.length
|
|
111
156
|
? html `
|
|
112
|
-
<ia-mgc-
|
|
157
|
+
<ia-mgc-plans
|
|
158
|
+
@editThisPlan=${async (event) => {
|
|
159
|
+
this.editingThisPlan = event.detail.plan;
|
|
160
|
+
this.viewToDisplay = 'editPlan';
|
|
161
|
+
this.dispatchEvent(new Event('ShowEditForm'));
|
|
162
|
+
await this.updateComplete;
|
|
163
|
+
}}
|
|
164
|
+
.plans=${this.plans}
|
|
165
|
+
></ia-mgc-plans>
|
|
113
166
|
`
|
|
114
|
-
:
|
|
167
|
+
: html `<ia-mgc-welcome
|
|
168
|
+
.patronName=${this.patronName}
|
|
169
|
+
></ia-mgc-welcome>`}
|
|
115
170
|
`;
|
|
116
171
|
}
|
|
117
172
|
};
|
|
@@ -127,6 +182,9 @@ __decorate([
|
|
|
127
182
|
__decorate([
|
|
128
183
|
property({ type: Array })
|
|
129
184
|
], MonthlyGivingCircle.prototype, "plans", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
property({ type: Object })
|
|
187
|
+
], MonthlyGivingCircle.prototype, "editingThisPlan", void 0);
|
|
130
188
|
__decorate([
|
|
131
189
|
property({ type: String, reflect: true })
|
|
132
190
|
], MonthlyGivingCircle.prototype, "viewToDisplay", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monthly-giving-circle.js","sourceRoot":"","sources":["../../src/monthly-giving-circle.ts"],"names":[],"mappings":"AAAA,gCAAgC;;AAEhC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,mBAAmB,CAAC;AAC3B,OAAO,SAAS,CAAC;AACjB,OAAO,4BAA4B,CAAC;AACpC,OAAO,YAAY,CAAC;AAEpB,OAAO,4BAA4B,CAAC;AASpC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAAnD;;QAC8B,eAAU,GAAW,EAA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1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAAe;AAEd;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAA0B;AAEzB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAY;AAEK;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0DAGlB;AAZb,mBAAmB;IAD/B,aAAa,CAAC,0BAA0B,CAAC;GAC7B,mBAAmB,CA0H/B;SA1HY,mBAAmB","sourcesContent":["/* eslint-disable no-debugger */\n\nimport { LitElement, html, TemplateResult, nothing, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport './welcome-message';\nimport './plans';\nimport './presentational/mgc-title';\nimport './receipts';\nimport type { IauxMgcReceipts } from './receipts';\nimport './presentational/ia-button';\n\nexport type AnUpdate = {\n message: string;\n status: 'success' | 'fail';\n donationId: string;\n};\n\n@customElement('ia-monthly-giving-circle')\nexport class MonthlyGivingCircle extends LitElement {\n @property({ type: String }) patronName: string = '';\n\n @property({ type: Array }) receipts = [];\n\n @property({ type: Array }) updates: AnUpdate[] = [];\n\n @property({ type: Array }) plans = [];\n\n @property({ type: String, reflect: true }) viewToDisplay:\n | 'welcome'\n | 'receipts'\n | 'plans' = 'welcome';\n\n protected createRenderRoot() {\n return this;\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('plans')) {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n }\n }\n\n get receiptListElement(): IauxMgcReceipts {\n return this.querySelector('ia-mgc-receipts') as IauxMgcReceipts;\n }\n\n updateReceived(update: AnUpdate) {\n this.receiptListElement.emailSent({\n id: update.donationId,\n emailStatus: update.status,\n });\n this.updates.unshift(update);\n }\n\n get showReceiptsCTA(): TemplateResult {\n return html`\n <ia-button\n class=\"link slim\"\n .clickHandler=${() => {\n this.viewToDisplay = 'receipts';\n this.dispatchEvent(new CustomEvent('ShowReceipts'));\n }}\n >\n View recent donation history\n </ia-button>\n `;\n }\n\n get headerSection(): TemplateResult {\n if (this.viewToDisplay === 'receipts') {\n return html`\n <ia-mgc-title titleStyle=\"default\">\n <span slot=\"title\">Recent donations</span>\n <span slot=\"action\">\n <ia-button\n class=\"link slim\"\n id=\"close-receipts\"\n .clickHandler=${async () => {\n this.viewToDisplay = 'welcome';\n this.dispatchEvent(new CustomEvent('ShowWelcome'));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-button>\n </span>\n </ia-mgc-title>\n `;\n }\n\n if (this.plans.length) {\n return html`\n <ia-mgc-title titleStyle=\"heart\">\n <span slot=\"title\">Monthly Giving Circle</span>\n <span slot=\"action\"\n >${this.receipts.length ? this.showReceiptsCTA : nothing}</span\n >\n </ia-mgc-title>\n `;\n }\n\n return html`\n <ia-mgc-title titleStyle=\"heart\">\n <span slot=\"title\">Monthly Giving Circle</span>\n <span slot=\"action\"\n >${this.receipts.length ? this.showReceiptsCTA : nothing}</span\n >\n </ia-mgc-title>\n `;\n }\n\n protected render() {\n return html`\n ${this.headerSection}\n ${this.viewToDisplay === 'receipts'\n ? html`\n <ia-mgc-receipts\n .receipts=${this.receipts}\n @EmailReceiptRequest=${(event: CustomEvent) => {\n console.log('EmailReceiptRequest', event.detail);\n this.dispatchEvent(\n new CustomEvent('EmailReceiptRequest', {\n detail: { ...event.detail },\n })\n );\n }}\n ></ia-mgc-receipts>\n `\n : nothing}\n ${this.viewToDisplay === 'plans'\n ? html` <ia-mgc-plans .plans=${this.plans}></ia-mgc-plans> `\n : nothing}\n ${this.viewToDisplay === 'welcome'\n ? html`\n <ia-mgc-welcome .patronName=${this.patronName}></ia-mgc-welcome>\n `\n : nothing}\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"monthly-giving-circle.js","sourceRoot":"","sources":["../../src/monthly-giving-circle.ts"],"names":[],"mappings":"AAAA,gCAAgC;;AA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AAE,MAAM,EAAE,CAAC;uDAAyB;AAEzB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAAe;AAEd;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAA6B;AAE5B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAY;AAEV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA+B;AAEf;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0DAIf;AAfhB,mBAAmB;IAD/B,aAAa,CAAC,0BAA0B,CAAC;GAC7B,mBAAmB,CA+L/B;SA/LY,mBAAmB","sourcesContent":["/* eslint-disable no-debugger */\n\nimport { LitElement, html, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport './welcome-message';\nimport './plans';\nimport './presentational/mgc-title';\nimport './receipts';\nimport type { IauxMgcReceipts } from './receipts';\nimport './presentational/ia-button';\nimport type { MonthlyPlan } from './models/plan';\nimport './edit-plan-form';\n\nexport type APlanUpdate = {\n plan?: MonthlyPlan;\n donationId?: string;\n status: 'success' | 'fail';\n action: 'receiptSent' | 'cancel';\n message: string;\n};\n\n@customElement('ia-monthly-giving-circle')\nexport class MonthlyGivingCircle extends LitElement {\n @property({ type: String }) patronName: string = '';\n\n @property({ type: Array }) receipts = [];\n\n @property({ type: Array }) updates: APlanUpdate[] = [];\n\n @property({ type: Array }) plans = [];\n\n @property({ type: Object }) editingThisPlan?: MonthlyPlan;\n\n @property({ type: String, reflect: true }) viewToDisplay:\n | 'welcome'\n | 'receipts'\n | 'plans'\n | 'editPlan' = 'welcome';\n\n protected createRenderRoot() {\n return this;\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('plans')) {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n }\n }\n\n get receiptListElement(): IauxMgcReceipts {\n return this.querySelector('ia-mgc-receipts') as IauxMgcReceipts;\n }\n\n /* Update Callback */\n updateReceived(update: APlanUpdate) {\n // log update\n this.updates.unshift(update);\n\n const { plan, donationId = '' } = update;\n const idToUse = plan?.id ?? donationId;\n const editingPlanIsUpdating = this.editingThisPlan?.id === idToUse;\n\n if (editingPlanIsUpdating) {\n console.log('edit received, mismatch plans', {\n planCurrentlyEditing: this.editingThisPlan,\n planReceived: update.plan,\n });\n return;\n }\n\n if (plan?.hasBeenCancelled) {\n this.editingThisPlan = undefined;\n this.viewToDisplay = 'plans';\n return;\n }\n\n this.receiptListElement.emailSent({\n id: idToUse,\n emailStatus: update.status,\n });\n }\n\n /* VIEWS */\n protected render() {\n const isEditingPlan =\n this.viewToDisplay === 'editPlan' && this.editingThisPlan;\n return html`\n ${this.sectionTitle}\n ${isEditingPlan\n ? html`<ia-mgc-edit-plan\n .plan=${this.editingThisPlan}\n .cancelPlanHandler=${(plan: MonthlyPlan) => {\n console.log('cancelPlan', plan);\n this.dispatchEvent(\n new CustomEvent('cancelPlan', {\n detail: { plan },\n })\n );\n }}\n ></ia-mgc-edit-plan>`\n : this.nonEditView}\n `;\n }\n\n get sectionTitle(): TemplateResult {\n let title = '';\n let titleStyle = '';\n let cta = html``;\n\n const receiptsCTA = html`\n <ia-button\n class=\"link slim\"\n .clickHandler=${async () => {\n this.viewToDisplay = 'receipts';\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('ShowReceipts'));\n }}\n >\n View recent donation history\n </ia-button>\n `;\n\n const displayReceiptsLink =\n this.receipts.length &&\n (this.viewToDisplay === 'plans' || this.viewToDisplay === 'welcome');\n\n switch (this.viewToDisplay) {\n case 'receipts':\n title = 'Recent donations';\n titleStyle = 'default';\n cta = html`<ia-button\n class=\"link slim\"\n id=\"close-receipts\"\n .clickHandler=${async () => {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n this.dispatchEvent(new CustomEvent('ShowWelcome'));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-button>`;\n break;\n\n case 'editPlan':\n title = 'Edit plan';\n titleStyle = 'default';\n cta = html`<ia-button\n class=\"primary\"\n id=\"close-edit-plan\"\n .clickHandler=${async () => {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n this.dispatchEvent(new CustomEvent('ShowWelcome'));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-button>`;\n break;\n\n default:\n title = 'Monthly Giving Circle';\n titleStyle = 'heart';\n if (displayReceiptsLink) {\n cta = receiptsCTA;\n }\n break;\n }\n\n return html`\n <ia-mgc-title titleStyle=${titleStyle}>\n <span slot=\"title\">${title}</span>\n <span slot=\"action\">${cta}</span>\n </ia-mgc-title>\n `;\n }\n\n get nonEditView(): TemplateResult {\n if (this.viewToDisplay === 'receipts') {\n return html`\n <ia-mgc-receipts\n .receipts=${this.receipts}\n @EmailReceiptRequest=${(event: CustomEvent) => {\n console.log('EmailReceiptRequest', event.detail);\n this.dispatchEvent(\n new CustomEvent('EmailReceiptRequest', {\n detail: { ...event.detail },\n })\n );\n }}\n ></ia-mgc-receipts>\n `;\n }\n\n return html`\n ${this.viewToDisplay === 'plans' && this.plans.length\n ? html`\n <ia-mgc-plans\n @editThisPlan=${async (event: CustomEvent) => {\n this.editingThisPlan = event.detail.plan;\n this.viewToDisplay = 'editPlan';\n this.dispatchEvent(new Event('ShowEditForm'));\n await this.updateComplete;\n }}\n .plans=${this.plans}\n ></ia-mgc-plans>\n `\n : html`<ia-mgc-welcome\n .patronName=${this.patronName}\n ></ia-mgc-welcome>`}\n `;\n }\n}\n"]}
|