Skip to content

Commit 8548bd5

Browse files
authored
Cancel form (#18)
1 parent 35d6500 commit 8548bd5

File tree

14 files changed

+766
-99
lines changed

14 files changed

+766
-99
lines changed

demo/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,21 @@
224224
}, returnTiming);
225225
});
226226

227+
mgcComponent.addEventListener('cancelPlan', async (e) => {
228+
const { plan } = e.detail;
229+
const currPlansList = mgcComponent.plans;
230+
const newPlansList = currPlansList.map((p) => {
231+
if (p.plan.token === plan.plan.token) {
232+
console.log('p 2 plan', p, plan);
233+
p.cancelPlan();
234+
}
235+
return p;
236+
});
237+
mgcComponent.plans = newPlansList;
238+
await mgcComponent.updateComplete;
239+
console.log("plan cancelled & plan list updated", mgcComponent.plans);
240+
})
241+
227242
// options hooks
228243
document.getElementById('toggle-receipts').addEventListener('click', async () => {
229244
if (showReceipts) {

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { MonthlyGivingCircle } from './src/monthly-giving-circle';
2-
export type { AnUpdate } from './src/monthly-giving-circle';
2+
export type { APlanUpdate } from './src/monthly-giving-circle';
33
export { Receipt } from './src/models/receipt';
44
export { MonthlyPlan } from './src/models/plan';

package-lock.json

Lines changed: 253 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"ghpages:generate": "gh-pages -t -d ghpages -m \"Build for $(git log --pretty=format:\"%h %an %ai %s\" -n1) [skip ci]\""
2828
},
2929
"dependencies": {
30+
"@internetarchive/donation-form": "^0.6.3",
31+
"@internetarchive/donation-form-section": "^0.3.6",
3032
"@internetarchive/iaux-notification-toast": "^0.0.0-alpha2",
3133
"@internetarchive/icon-donate": "^1.3.4",
3234
"lit": "^2.8.0"

src/edit-plan-form.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { LitElement, html } from 'lit';
2+
import { customElement, property } from 'lit/decorators.js';
3+
4+
import type { MonthlyPlan } from './models/plan';
5+
import './form-sections/cancel';
6+
7+
@customElement('ia-mgc-edit-plan')
8+
export class IauxEditPlanForm extends LitElement {
9+
@property({ type: Object }) plan?: MonthlyPlan;
10+
11+
@property({ type: Object }) cancelPlanHandler?: (plan: MonthlyPlan) => void;
12+
13+
render() {
14+
return html`
15+
<section class="mgc-edit-plan">
16+
<hr />
17+
<ia-mgc-cancel-plan
18+
.plan=${this.plan}
19+
@cancelPlan=${() => {
20+
if (this.plan) {
21+
this.cancelPlanHandler?.(this.plan);
22+
}
23+
}}
24+
></ia-mgc-cancel-plan>
25+
</section>
26+
`;
27+
}
28+
}

0 commit comments

Comments
 (0)