@internetarchive/donation-monthly-portal 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
2
  import '@internetarchive/donation-form-section';
3
3
  import { DonationPaymentInfo } from '@internetarchive/donation-form-data-models';
4
4
  import type { MonthlyPlan } from '../models/plan';
5
+ import '../presentational/donation-section-info';
5
6
  import '../presentational/mgc-button';
6
7
  import '../presentational/mgc-update-status';
7
8
  export declare class MGCEditPlanAmount extends LitElement {
@@ -3,6 +3,7 @@ import { LitElement, html, nothing, css, } from 'lit';
3
3
  import { customElement, property, query } from 'lit/decorators.js';
4
4
  import '@internetarchive/donation-form-section';
5
5
  import { DonationPaymentInfo, DonationType, } from '@internetarchive/donation-form-data-models';
6
+ import '../presentational/donation-section-info';
6
7
  import '../presentational/mgc-button';
7
8
  import '../presentational/mgc-update-status';
8
9
  let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
@@ -35,22 +36,13 @@ let MGCEditPlanAmount = class MGCEditPlanAmount extends LitElement {
35
36
  <section>
36
37
  <donation-form-section badgemode="hidebadge" headline="Amount">
37
38
  ${!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-mgc-button
45
- id="edit-amount"
46
- class="ia-button link"
47
- .clickHandler=${() => {
39
+ ? html `<ia-mgc-form-section-info
40
+ @editingRequested=${() => {
48
41
  this.currentlyEditing = true;
49
42
  this.clearStatusMessaging();
50
43
  }}
51
- >
52
- Edit...
53
- </ia-mgc-button>`
44
+ ><span>USD $${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.amount}</span>
45
+ </ia-mgc-form-section-info>`
54
46
  : nothing}
55
47
  ${this.currentlyEditing ? this.editAmountForm : nothing}
56
48
  </donation-form-section>
@@ -1 +1 @@
1
- {"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/form-sections/amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,OAAO,EACP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,wCAAwC,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,YAAY,GACb,MAAM,4CAA4C,CAAC;AAGpD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,qCAAqC,CAAC;AAG7C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,UAAU;IAAjD;;QAM8B,cAAS,GAAW,CAAC,CAAC;QAEN,qBAAgB,GAAY,KAAK,CAAC;QAEjD,cAAS,GAAY,KAAK,CAAC;QAE5B,kBAAa,GAAW,EAAE,CAAC;QAE3B,iBAAY,GAAW,EAAE,CAAC;QAE1B,iBAAY,GAA4B,EAAE,CAAC;IAuTzE,CAAC;IAnTC,OAAO,CAAC,OAAuB;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE;YACpC,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC5D,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;SACnB;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;YACnE,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;IACH,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O,EAAE,IAAI,EAAE,CAAC;2DAAmC;AAEjD;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAA4B;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAA4B;AAE3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA2B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA4C;AAExD;IAAd,KAAK,CAAC,MAAM,CAAC;+CAAwB;AAlB3B,iBAAiB;IAD7B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,iBAAiB,CAuU7B;SAvUY,iBAAiB","sourcesContent":["import {\n LitElement,\n html,\n PropertyValues,\n nothing,\n css,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport '@internetarchive/donation-form-section';\nimport {\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\n\nimport type { MonthlyPlan } from '../models/plan';\nimport '../presentational/mgc-button';\nimport type { MGCButton } from '../presentational/mgc-button';\nimport '../presentational/mgc-update-status';\n\n@customElement('ia-mgc-edit-plan-amount')\nexport class MGCEditPlanAmount extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n // captures the changes made to the amount && calculates the total amount with fees\n @property({ type: Object }) donationPaymentInfo?: DonationPaymentInfo;\n\n @property({ type: Number }) newAmount: number = 0;\n\n @property({ type: Boolean, reflect: true }) currentlyEditing: boolean = false;\n\n @property({ type: Boolean }) coverFees: boolean = false;\n\n @property({ type: String }) updateMessage: string = '';\n\n @property({ type: String }) errorMessage: string = '';\n\n @property({ type: String }) updateStatus: 'success' | 'fail' | '' = '';\n\n @query('form') form!: HTMLFormElement;\n\n updated(changed: PropertyValues) {\n if (changed.has('plan') && this.plan) {\n this.captureAmountChanges();\n }\n if (changed.has('coverFees')) {\n this.captureAmountChanges();\n }\n if (changed.has('currentlyEditing') && this.currentlyEditing) {\n this.form.focus();\n }\n\n if (changed.has('donationPaymentInfo') && !this.donationPaymentInfo) {\n this.captureAmountChanges();\n }\n }\n\n protected render() {\n return html`\n <section>\n <donation-form-section badgemode=\"hidebadge\" headline=\"Amount\">\n ${!this.currentlyEditing\n ? html` <p class=\"current-amount\">\n USD $${this.plan?.amount}\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </p>\n <ia-mgc-button\n id=\"edit-amount\"\n class=\"ia-button link\"\n .clickHandler=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n >\n Edit...\n </ia-mgc-button>`\n : nothing}\n ${this.currentlyEditing ? this.editAmountForm : nothing}\n </donation-form-section>\n </section>\n `;\n }\n\n /* External Function that is called by consumer to tell the form there has been data update */\n async amountUpdated(status: 'success' | 'fail') {\n this.clearInputField();\n\n this.updateStatus = status;\n this.updateMessage =\n status === 'success' ? 'Amount updated' : 'Failed. Try again.';\n\n if (status === 'success') {\n this.closeForm();\n await this.updateComplete;\n\n this.updateStatus = status;\n this.updateMessage = 'Amount updated';\n\n return;\n }\n\n (\n this.form.querySelector('ia-mgc-button#update-amount') as MGCButton\n ).isDisabled = false;\n\n this.captureAmountChanges();\n\n await this.updateComplete;\n }\n\n /* Dispatches amount change request */\n requestAmountUpdate(e: Event): void {\n e.preventDefault();\n\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n this.newAmount = Number(input.value);\n\n this.captureAmountChanges(this.newAmount);\n\n console.log('<plan-amount> - update amount', {\n newValue: this.newAmount,\n oldValue: this.plan?.plan.amount,\n display: this.donationPaymentInfo?.amount,\n });\n const newAmount = Number(\n DonationPaymentInfo.calculateTotal(\n Number(this.donationPaymentInfo?.amount),\n this.coverFees\n )\n );\n this.dispatchEvent(\n new CustomEvent('updateAmount', {\n detail: {\n plan: this.plan,\n amount: newAmount,\n baseAmount: this.donationPaymentInfo?.amount,\n coverFees: this.coverFees,\n feeCovered: this.donationPaymentInfo?.feeAmountCovered,\n },\n })\n );\n }\n\n /* captures form changes */\n captureAmountChanges(newAmount?: number) {\n if (!this.donationPaymentInfo && this.plan) {\n this.donationPaymentInfo = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: 0,\n coverFees: true,\n });\n return;\n }\n\n let newPlan;\n if (newAmount) {\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: newAmount,\n coverFees: true,\n });\n } else {\n const amount = this.donationPaymentInfo\n ? this.donationPaymentInfo.amount\n : this.plan!.amount;\n\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount,\n coverFees: true,\n });\n }\n\n this.donationPaymentInfo = newPlan;\n }\n\n closeForm() {\n this.clearInputField();\n this.clearStatusMessaging();\n this.currentlyEditing = false;\n this.coverFees = false;\n this.errorMessage = '';\n }\n\n clearInputField() {\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n input.value = '';\n this.newAmount = 0;\n this.donationPaymentInfo = undefined;\n }\n\n async clearStatusMessaging() {\n this.errorMessage = '';\n this.updateMessage = '';\n this.updateStatus = '';\n await this.updateComplete;\n }\n\n /* DISPLAY */\n totalAmountWithFees(): number {\n if (this.newAmount === 0) {\n return 0;\n }\n\n return DonationPaymentInfo.calculateTotal(this.newAmount, this.coverFees);\n }\n\n get coveredFeesText() {\n return `I'll generously add $${this.donationPaymentInfo?.feeAmountCovered} to cover fees.`;\n }\n\n get editAmountForm(): TemplateResult {\n return html`\n <section>\n <form id=\"edit-plan-amount\">\n <p>Current donation amount: $${this.plan?.amount}</p>\n <div>\n $\n <input\n min=\"1\"\n max=\"9999\"\n type=\"number\"\n id=\"amount\"\n name=\"amount\"\n required=\"true\"\n @focus=${() => this.clearStatusMessaging()}\n @input=${(e: Event) => {\n const newAmount = Number((e.target as HTMLInputElement).value);\n this.captureAmountChanges(newAmount);\n this.newAmount = newAmount;\n }}\n />\n / month\n </div>\n <div>\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"cover-fees\"\n tabindex=\"0\"\n @change=${(e: Event) => {\n const input = e.target as HTMLInputElement;\n const coverFees = input.checked;\n this.coverFees = coverFees;\n this.captureAmountChanges();\n }}\n />\n <label for=\"cover-fees\">${this.coveredFeesText}</label>\n </div>\n <p>Total: USD $${this.totalAmountWithFees()}</p>\n <div class=\"cta-container\">\n <ia-mgc-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-mgc-button>\n <ia-mgc-button\n id=\"update-amount\"\n class=\"ia-button primary\"\n type=\"submit\"\n .clickHandler=${async (e: Event, iaButton: MGCButton) => {\n this.clearStatusMessaging();\n\n if (!this.newAmount) {\n this.errorMessage = 'Please enter a new amount';\n return;\n }\n\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton.updateComplete;\n\n // check if request is in range\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n const requestedAmount = Number(input.value) ?? 0;\n const amountTooLow = requestedAmount < 1;\n const amountTooHigh = requestedAmount >= 9999;\n if (amountTooLow) {\n this.errorMessage = 'Please enter a valid amount';\n }\n if (amountTooHigh) {\n this.errorMessage =\n 'Amount must be less than $9,999. Would you like to donate more? Please contact us at donations@archive.org';\n }\n if (amountTooHigh || amountTooLow) {\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = false;\n await iaButton.updateComplete;\n return;\n }\n\n this.requestAmountUpdate(e);\n }}\n >\n Update\n </ia-mgc-button>\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </div>\n </div>\n <p class=\"error\">${this.errorMessage}</p>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n input#amount {\n width: 50px;\n }\n\n .cta-container {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-content: center;\n justify-content: flex-start;\n align-items: center;\n gap: 10px;\n }\n\n p.error {\n color: var(--mgc-warning-color-dark, #bb0505);\n }\n\n ia-mgc-update-status {\n display: inline-block;\n margin-left: 1rem;\n }\n\n .checkbox-option-container {\n margin: 10px 0;\n display: flex;\n }\n `;\n}\n"]}
1
+ {"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/form-sections/amount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,OAAO,EACP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,wCAAwC,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,YAAY,GACb,MAAM,4CAA4C,CAAC;AAGpD,OAAO,yCAAyC,CAAC;AACjD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,qCAAqC,CAAC;AAG7C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,UAAU;IAAjD;;QAM8B,cAAS,GAAW,CAAC,CAAC;QAEN,qBAAgB,GAAY,KAAK,CAAC;QAEjD,cAAS,GAAY,KAAK,CAAC;QAE5B,kBAAa,GAAW,EAAE,CAAC;QAE3B,iBAAY,GAAW,EAAE,CAAC;QAE1B,iBAAY,GAA4B,EAAE,CAAC;IA8SzE,CAAC;IA1SC,OAAO,CAAC,OAAuB;QAC7B,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE;YACpC,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC5B,IAAI,CAAC,oBAAoB,EAAE,CAAC;SAC7B;QACD,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC5D,IAAI,CAAC,IAAI,CAAC,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AAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAuB;AAEN;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DAAmC;AAEjD;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAA4B;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAA4B;AAE3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA2B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA4C;AAExD;IAAd,KAAK,CAAC,MAAM,CAAC;+CAAwB;AAlB3B,iBAAiB;IAD7B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,iBAAiB,CA8T7B;SA9TY,iBAAiB","sourcesContent":["import {\n LitElement,\n html,\n PropertyValues,\n nothing,\n css,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport '@internetarchive/donation-form-section';\nimport {\n DonationPaymentInfo,\n DonationType,\n} from '@internetarchive/donation-form-data-models';\n\nimport type { MonthlyPlan } from '../models/plan';\nimport '../presentational/donation-section-info';\nimport '../presentational/mgc-button';\nimport type { MGCButton } from '../presentational/mgc-button';\nimport '../presentational/mgc-update-status';\n\n@customElement('ia-mgc-edit-plan-amount')\nexport class MGCEditPlanAmount extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n // captures the changes made to the amount && calculates the total amount with fees\n @property({ type: Object }) donationPaymentInfo?: DonationPaymentInfo;\n\n @property({ type: Number }) newAmount: number = 0;\n\n @property({ type: Boolean, reflect: true }) currentlyEditing: boolean = false;\n\n @property({ type: Boolean }) coverFees: boolean = false;\n\n @property({ type: String }) updateMessage: string = '';\n\n @property({ type: String }) errorMessage: string = '';\n\n @property({ type: String }) updateStatus: 'success' | 'fail' | '' = '';\n\n @query('form') form!: HTMLFormElement;\n\n updated(changed: PropertyValues) {\n if (changed.has('plan') && this.plan) {\n this.captureAmountChanges();\n }\n if (changed.has('coverFees')) {\n this.captureAmountChanges();\n }\n if (changed.has('currentlyEditing') && this.currentlyEditing) {\n this.form.focus();\n }\n\n if (changed.has('donationPaymentInfo') && !this.donationPaymentInfo) {\n this.captureAmountChanges();\n }\n }\n\n protected render() {\n return html`\n <section>\n <donation-form-section badgemode=\"hidebadge\" headline=\"Amount\">\n ${!this.currentlyEditing\n ? html`<ia-mgc-form-section-info\n @editingRequested=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n ><span>USD $${this.plan?.amount}</span>\n </ia-mgc-form-section-info>`\n : nothing}\n ${this.currentlyEditing ? this.editAmountForm : nothing}\n </donation-form-section>\n </section>\n `;\n }\n\n /* External Function that is called by consumer to tell the form there has been data update */\n async amountUpdated(status: 'success' | 'fail') {\n this.clearInputField();\n\n this.updateStatus = status;\n this.updateMessage =\n status === 'success' ? 'Amount updated' : 'Failed. Try again.';\n\n if (status === 'success') {\n this.closeForm();\n await this.updateComplete;\n\n this.updateStatus = status;\n this.updateMessage = 'Amount updated';\n\n return;\n }\n\n (\n this.form.querySelector('ia-mgc-button#update-amount') as MGCButton\n ).isDisabled = false;\n\n this.captureAmountChanges();\n\n await this.updateComplete;\n }\n\n /* Dispatches amount change request */\n requestAmountUpdate(e: Event): void {\n e.preventDefault();\n\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n this.newAmount = Number(input.value);\n\n this.captureAmountChanges(this.newAmount);\n\n console.log('<plan-amount> - update amount', {\n newValue: this.newAmount,\n oldValue: this.plan?.plan.amount,\n display: this.donationPaymentInfo?.amount,\n });\n const newAmount = Number(\n DonationPaymentInfo.calculateTotal(\n Number(this.donationPaymentInfo?.amount),\n this.coverFees\n )\n );\n this.dispatchEvent(\n new CustomEvent('updateAmount', {\n detail: {\n plan: this.plan,\n amount: newAmount,\n baseAmount: this.donationPaymentInfo?.amount,\n coverFees: this.coverFees,\n feeCovered: this.donationPaymentInfo?.feeAmountCovered,\n },\n })\n );\n }\n\n /* captures form changes */\n captureAmountChanges(newAmount?: number) {\n if (!this.donationPaymentInfo && this.plan) {\n this.donationPaymentInfo = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: 0,\n coverFees: true,\n });\n return;\n }\n\n let newPlan;\n if (newAmount) {\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount: newAmount,\n coverFees: true,\n });\n } else {\n const amount = this.donationPaymentInfo\n ? this.donationPaymentInfo.amount\n : this.plan!.amount;\n\n newPlan = new DonationPaymentInfo({\n donationType: DonationType.Monthly,\n amount,\n coverFees: true,\n });\n }\n\n this.donationPaymentInfo = newPlan;\n }\n\n closeForm() {\n this.clearInputField();\n this.clearStatusMessaging();\n this.currentlyEditing = false;\n this.coverFees = false;\n this.errorMessage = '';\n }\n\n clearInputField() {\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n input.value = '';\n this.newAmount = 0;\n this.donationPaymentInfo = undefined;\n }\n\n async clearStatusMessaging() {\n this.errorMessage = '';\n this.updateMessage = '';\n this.updateStatus = '';\n await this.updateComplete;\n }\n\n /* DISPLAY */\n totalAmountWithFees(): number {\n if (this.newAmount === 0) {\n return 0;\n }\n\n return DonationPaymentInfo.calculateTotal(this.newAmount, this.coverFees);\n }\n\n get coveredFeesText() {\n return `I'll generously add $${this.donationPaymentInfo?.feeAmountCovered} to cover fees.`;\n }\n\n get editAmountForm(): TemplateResult {\n return html`\n <section>\n <form id=\"edit-plan-amount\">\n <p>Current donation amount: $${this.plan?.amount}</p>\n <div>\n $\n <input\n min=\"1\"\n max=\"9999\"\n type=\"number\"\n id=\"amount\"\n name=\"amount\"\n required=\"true\"\n @focus=${() => this.clearStatusMessaging()}\n @input=${(e: Event) => {\n const newAmount = Number((e.target as HTMLInputElement).value);\n this.captureAmountChanges(newAmount);\n this.newAmount = newAmount;\n }}\n />\n / month\n </div>\n <div>\n <div class=\"checkbox-option-container\">\n <input\n type=\"checkbox\"\n id=\"cover-fees\"\n tabindex=\"0\"\n @change=${(e: Event) => {\n const input = e.target as HTMLInputElement;\n const coverFees = input.checked;\n this.coverFees = coverFees;\n this.captureAmountChanges();\n }}\n />\n <label for=\"cover-fees\">${this.coveredFeesText}</label>\n </div>\n <p>Total: USD $${this.totalAmountWithFees()}</p>\n <div class=\"cta-container\">\n <ia-mgc-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-mgc-button>\n <ia-mgc-button\n id=\"update-amount\"\n class=\"ia-button primary\"\n type=\"submit\"\n .clickHandler=${async (e: Event, iaButton: MGCButton) => {\n this.clearStatusMessaging();\n\n if (!this.newAmount) {\n this.errorMessage = 'Please enter a new amount';\n return;\n }\n\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton.updateComplete;\n\n // check if request is in range\n const input = this.form.querySelector(\n 'input[name=\"amount\"]'\n ) as HTMLInputElement;\n const requestedAmount = Number(input.value) ?? 0;\n const amountTooLow = requestedAmount < 1;\n const amountTooHigh = requestedAmount >= 9999;\n if (amountTooLow) {\n this.errorMessage = 'Please enter a valid amount';\n }\n if (amountTooHigh) {\n this.errorMessage =\n 'Amount must be less than $9,999. Would you like to donate more? Please contact us at donations@archive.org';\n }\n if (amountTooHigh || amountTooLow) {\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = false;\n await iaButton.updateComplete;\n return;\n }\n\n this.requestAmountUpdate(e);\n }}\n >\n Update\n </ia-mgc-button>\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </div>\n </div>\n <p class=\"error\">${this.errorMessage}</p>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n input#amount {\n width: 50px;\n }\n\n .cta-container {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-content: center;\n justify-content: flex-start;\n align-items: center;\n gap: 10px;\n }\n\n p.error {\n color: var(--mgc-warning-color-dark, #bb0505);\n }\n\n ia-mgc-update-status {\n display: inline-block;\n margin-left: 1rem;\n }\n\n .checkbox-option-container {\n margin: 10px 0;\n display: flex;\n }\n `;\n}\n"]}
@@ -42,22 +42,13 @@ let MGCEditPlanDate = class MGCEditPlanDate extends LitElement {
42
42
  headline="Change next donation date"
43
43
  >
44
44
  ${!this.currentlyEditing
45
- ? html ` <p class="current-date">
46
- ${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.nextBillingDateLocale}
47
- <ia-mgc-update-status .status=${this.updateStatus}
48
- >${this.updateMessage}</ia-mgc-update-status
49
- >
50
- </p>
51
- <ia-mgc-button
52
- id="open-edit-date-form"
53
- class="ia-button link"
54
- .clickHandler=${() => {
45
+ ? html `<ia-mgc-form-section-info
46
+ @editingRequested=${() => {
55
47
  this.currentlyEditing = true;
56
48
  this.clearStatusMessaging();
57
49
  }}
58
- >
59
- Edit...
60
- </ia-mgc-button>`
50
+ ><span>${(_a = this.plan) === null || _a === void 0 ? void 0 : _a.nextBillingDateLocale}</span>
51
+ </ia-mgc-form-section-info>`
61
52
  : nothing}
62
53
  ${this.currentlyEditing ? this.editDateForm : nothing}
63
54
  </donation-form-section>
@@ -1 +1 @@
1
- {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/form-sections/date.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,OAAO,EACP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,wCAAwC,CAAC;AAGhD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,qCAAqC,CAAC;AAU7C,IAAK,wBAMJ;AAND,WAAK,wBAAwB;IAC3B,0FAA8D,CAAA;IAC9D,8EAAkD,CAAA;IACl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BQ,sBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BlB,CAAC;AA9W0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAkB;AAED;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yDAAmC;AAEjD;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qDAA+B;AAE/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA4B;AAE3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA2B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA6B;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA4C;AAExD;IAAd,KAAK,CAAC,MAAM,CAAC;6CAAwB;AAEC;IAAtC,KAAK,CAAC,8BAA8B,CAAC;yDAA8B;AAGpE;IADC,KAAK,CAAC,8BAA8B,CAAC;kDACT;AAtBlB,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAgX3B;SAhXY,eAAe","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';\n\nimport type { MonthlyPlan } from '../models/plan';\nimport '../presentational/mgc-button';\nimport type { MGCButton } from '../presentational/mgc-button';\nimport '../presentational/mgc-update-status';\n\ntype InvalidDateErrorCode =\n | 'invalid_date'\n | 'date_too_early'\n | 'second_donation_this_month'\n | 'date_out_of_range'\n | 'same_next_billing_date'\n | '';\n\nenum InvalidDateErrorMessages {\n invalid_date = 'Please enter a valid date format (YYYY-MM-DD)',\n date_too_early = 'Date must be at least tomorrow.',\n second_donation_this_month = 'The date you selected will result in an additional donation for this month.',\n date_out_of_range = 'New donation date must be within the next 12 months.',\n same_next_billing_date = '',\n}\n@customElement('ia-mgc-edit-date')\nexport class MGCEditPlanDate extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n @property({ type: String }) newDate?: string;\n\n @property({ type: Boolean, reflect: true }) currentlyEditing: boolean = false;\n\n @property({ type: Boolean }) allowEditing: boolean = false;\n\n @property({ type: String }) updateMessage: string = '';\n\n @property({ type: String }) errorMessage: string = '';\n\n @property({ type: String }) warningMessage: string = '';\n\n @property({ type: String }) updateStatus: 'success' | 'fail' | '' = '';\n\n @query('form') form!: HTMLFormElement;\n\n @query('form ia-mgc-button#edit-date') formSubmitButton!: MGCButton;\n\n @query('form input[name=\"edit-date\"]')\n dateInput!: HTMLInputElement;\n\n willUpdate(changed: PropertyValues) {\n if (this.dateInput && changed.has('plan') && this.plan) {\n this.dateInput.setAttribute('min', this.minDate);\n this.dateInput.setAttribute('max', this.maxDate);\n }\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('currentlyEditing') && this.currentlyEditing) {\n this.dateInput.focus();\n }\n }\n\n protected render() {\n return html`\n <section>\n <donation-form-section\n badgemode=\"hidebadge\"\n headline=\"Change next donation date\"\n >\n ${!this.currentlyEditing\n ? html` <p class=\"current-date\">\n ${this.plan?.nextBillingDateLocale}\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </p>\n <ia-mgc-button\n id=\"open-edit-date-form\"\n class=\"ia-button link\"\n .clickHandler=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n >\n Edit...\n </ia-mgc-button>`\n : nothing}\n ${this.currentlyEditing ? this.editDateForm : 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 dateUpdated(status: 'success' | 'fail') {\n this.clearInputField();\n\n this.updateStatus = status;\n this.updateMessage =\n status === 'success'\n ? 'Date updated'\n : 'Failed to update date, please try again';\n\n if (status === 'success') {\n this.closeForm();\n await this.updateComplete;\n return;\n }\n\n this.allowEditing = false;\n await this.updateComplete;\n }\n\n /* Dispatches edit-date change request */\n requestDateUpdate(e: Event): void {\n e.preventDefault();\n this.dispatchEvent(\n new CustomEvent('updateDate', {\n detail: {\n plan: this.plan,\n newDate: this.newDate,\n },\n })\n );\n }\n\n closeForm() {\n this.clearInputField();\n this.clearStatusMessaging();\n this.currentlyEditing = false;\n this.allowEditing = false;\n }\n\n clearInputField() {\n this.dateInput.value = '';\n this.newDate = undefined;\n }\n\n formatDateToYYYYMMDD(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\n const dateNum = String(date.getDate()).padStart(2, '0');\n return `${year}-${month}-${dateNum}`;\n }\n\n async clearStatusMessaging() {\n this.errorMessage = '';\n this.warningMessage = '';\n this.updateMessage = '';\n this.updateStatus = '';\n await this.updateComplete;\n }\n\n /* @param string dateString - YYYYY-MM-DD */\n validateChosenDate(dateString: string): {\n valid: boolean;\n errorCode: InvalidDateErrorCode | '';\n } {\n if (!dateString) {\n return {\n valid: false,\n errorCode: 'invalid_date',\n };\n }\n\n let validDate;\n try {\n validDate = new Date(`${dateString}T00:00:00`);\n } catch (error) {\n return {\n valid: false,\n errorCode: 'invalid_date',\n };\n }\n\n // Check if minimum date is at least tomorrow\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const tomorrow = new Date(today);\n tomorrow.setDate(today.getDate() + 1); // Set to tomorrow\n\n const chosenDate = new Date(validDate);\n chosenDate.setHours(0, 0, 0, 0);\n\n // check input value against next billing date\n const isNextBillingDate = this.plan?.nextBillingDate\n ? this.formatDateToYYYYMMDD(new Date(this.plan.nextBillingDate)) ===\n this.formatDateToYYYYMMDD(chosenDate)\n : false;\n if (isNextBillingDate) {\n return {\n valid: false,\n errorCode: 'same_next_billing_date',\n };\n }\n\n if (chosenDate < today) {\n return {\n valid: false,\n errorCode: 'date_too_early',\n };\n }\n\n // Check if the new date is within the next 12 months\n const twelveMonthsFromNow = new Date(today);\n twelveMonthsFromNow.setFullYear(twelveMonthsFromNow.getFullYear() + 1);\n\n if (chosenDate > twelveMonthsFromNow) {\n return {\n valid: false,\n errorCode: 'date_out_of_range',\n };\n }\n\n // Check if there has been a donation in the last month\n const lastDonationDate = this.plan?.payment.lastBillingDate.date\n ? new Date(this.plan?.payment.lastBillingDate.date)\n : null;\n\n if (lastDonationDate) {\n const lastDonationMonth = lastDonationDate.getMonth();\n const lastDonationYear = lastDonationDate.getFullYear();\n\n const thisYear = validDate.getFullYear();\n const thisMonth = validDate.getMonth();\n const isInLastMonth =\n thisYear === lastDonationYear && thisMonth === lastDonationMonth;\n\n if (isInLastMonth) {\n return {\n valid: true,\n errorCode: 'second_donation_this_month',\n };\n }\n }\n\n return {\n valid: true,\n errorCode: '',\n };\n }\n\n /* DISPLAY */\n get minDate(): string {\n const today = new Date();\n const tomorrow = new Date(today);\n tomorrow.setDate(today.getDate() + 1); // Set to tomorrow\n const year = tomorrow.getFullYear();\n const month = String(tomorrow.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\n const dateString = String(tomorrow.getDate()).padStart(2, '0');\n return `${year}-${month}-${dateString}`;\n }\n\n get maxDate(): string {\n const today = new Date();\n const year = today.getFullYear() + 1; // Allow up to one year in the future\n const month = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\n const dateString = String(today.getDate()).padStart(2, '0');\n return `${year}-${month}-${dateString}`;\n }\n\n get editDateForm(): TemplateResult {\n const nextBillingDateYYYYMMDD = this.plan?.nextBillingDate\n ? this.formatDateToYYYYMMDD(new Date(this.plan.nextBillingDate))\n : '';\n const inputValueToUse = this.dateInput?.value ?? nextBillingDateYYYYMMDD;\n return html`\n <section>\n <form id=\"edit-date\">\n <p id=\"form-info-last-donation-date\">\n Last donation date: ${this.plan?.lastBillingDateLocale}\n </p>\n\n <p id=\"form-info-next-donation-date\">\n Next donation date: ${this.plan?.nextBillingDateLocale}\n </p>\n <div class=\"date-holder\">\n <input\n required\n type=\"date\"\n id=\"edit-date\"\n name=\"edit-date\"\n min=${this.minDate}\n max=${this.maxDate}\n .value=${inputValueToUse}\n @focus=${() => this.clearStatusMessaging()}\n @change=${async () => {\n this.clearStatusMessaging();\n await this.updateComplete;\n\n const inputValue = this.dateInput.value;\n const { valid, errorCode } =\n this.validateChosenDate(inputValue);\n\n this.allowEditing = valid;\n\n if (errorCode) {\n if (errorCode === 'second_donation_this_month') {\n this.errorMessage = InvalidDateErrorMessages[errorCode];\n this.warningMessage =\n 'You have already made a donation this month.';\n } else {\n this.errorMessage = InvalidDateErrorMessages[errorCode];\n this.newDate = undefined;\n return;\n }\n }\n\n const chosenDate = new Date(`${inputValue}T00:00:00`);\n const newDate = new Date(chosenDate).toISOString();\n this.newDate = newDate;\n }}\n />\n </div>\n <div>\n <div class=\"cta-container\">\n <ia-mgc-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-mgc-button>\n <ia-mgc-button\n id=\"edit-date\"\n class=\"ia-button primary\"\n type=\"submit\"\n .isDisabled=${!this.allowEditing}\n .clickHandler=${async (e: Event, iaButton: MGCButton) => {\n this.clearStatusMessaging();\n\n if (!this.newDate) {\n this.errorMessage = 'Please enter a valid date';\n return;\n }\n\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton.updateComplete;\n\n this.requestDateUpdate(e);\n }}\n >\n Update\n </ia-mgc-button>\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </div>\n </div>\n <p class=\"error error-msg\">\n ${this.warningMessage\n ? html`<span>${this.warningMessage}</span><br />`\n : ''}\n ${this.errorMessage}\n </p>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n input[name='edit-date'] {\n margin: 10px 0;\n min-width: 140px;\n }\n\n .cta-container {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-content: center;\n justify-content: flex-start;\n align-items: center;\n gap: 10px;\n }\n\n p.error {\n color: var(--mgc-warning-color-dark, #bb0505);\n }\n\n ia-mgc-update-status {\n display: inline-block;\n margin-left: 1rem;\n }\n\n .checkbox-option-container {\n margin: 10px 0;\n display: flex;\n }\n `;\n}\n"]}
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/form-sections/date.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EAEJ,OAAO,EACP,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,wCAAwC,CAAC;AAGhD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,qCAAqC,CAAC;AAU7C,IAAK,wBAMJ;AAND,WAAK,wBAAwB;IAC3B,0FAA8D,CAAA;IAC9D,8EAAkD,CAAA;IAClD,sIAA0G,CAAA;IAC1G,sGAA0E,CAAA;IAC1E,uDAA2B,CAAA;AAC7B,CAAC,EANI,wBAAwB,KAAxB,wBAAwB,QAM5B;AAED,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,UAAU;IAA/C;;QAK8C,qBAAgB,GAAY,KAAK,CAAC;QAEjD,iBAAY,GAAY,KAAK,CAAC;QAE/B,kBAAa,GAAW,EAAE,CAAC;QAE3B,iBAAY,GAAW,EAAE,CAAC;QAE1B,mBAAc,GAAW,EAAE,CAAC;QAE5B,iBAAY,GAA4B,EAAE,CAAC;IAwVzE,CAAC;IA/UC,UAAU,CAAC,OAAuB;QAChC,IAAI,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE;YACtD,IAAI,CAAC,SAA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E,CAAC;uDAA6B;AAE5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA4C;AAExD;IAAd,KAAK,CAAC,MAAM,CAAC;6CAAwB;AAEC;IAAtC,KAAK,CAAC,8BAA8B,CAAC;yDAA8B;AAGpE;IADC,KAAK,CAAC,8BAA8B,CAAC;kDACT;AAtBlB,eAAe;IAD3B,aAAa,CAAC,kBAAkB,CAAC;GACrB,eAAe,CAuW3B;SAvWY,eAAe","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';\n\nimport type { MonthlyPlan } from '../models/plan';\nimport '../presentational/mgc-button';\nimport type { MGCButton } from '../presentational/mgc-button';\nimport '../presentational/mgc-update-status';\n\ntype InvalidDateErrorCode =\n | 'invalid_date'\n | 'date_too_early'\n | 'second_donation_this_month'\n | 'date_out_of_range'\n | 'same_next_billing_date'\n | '';\n\nenum InvalidDateErrorMessages {\n invalid_date = 'Please enter a valid date format (YYYY-MM-DD)',\n date_too_early = 'Date must be at least tomorrow.',\n second_donation_this_month = 'The date you selected will result in an additional donation for this month.',\n date_out_of_range = 'New donation date must be within the next 12 months.',\n same_next_billing_date = '',\n}\n@customElement('ia-mgc-edit-date')\nexport class MGCEditPlanDate extends LitElement {\n @property({ type: Object }) plan?: MonthlyPlan;\n\n @property({ type: String }) newDate?: string;\n\n @property({ type: Boolean, reflect: true }) currentlyEditing: boolean = false;\n\n @property({ type: Boolean }) allowEditing: boolean = false;\n\n @property({ type: String }) updateMessage: string = '';\n\n @property({ type: String }) errorMessage: string = '';\n\n @property({ type: String }) warningMessage: string = '';\n\n @property({ type: String }) updateStatus: 'success' | 'fail' | '' = '';\n\n @query('form') form!: HTMLFormElement;\n\n @query('form ia-mgc-button#edit-date') formSubmitButton!: MGCButton;\n\n @query('form input[name=\"edit-date\"]')\n dateInput!: HTMLInputElement;\n\n willUpdate(changed: PropertyValues) {\n if (this.dateInput && changed.has('plan') && this.plan) {\n this.dateInput.setAttribute('min', this.minDate);\n this.dateInput.setAttribute('max', this.maxDate);\n }\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('currentlyEditing') && this.currentlyEditing) {\n this.dateInput.focus();\n }\n }\n\n protected render() {\n return html`\n <section>\n <donation-form-section\n badgemode=\"hidebadge\"\n headline=\"Change next donation date\"\n >\n ${!this.currentlyEditing\n ? html`<ia-mgc-form-section-info\n @editingRequested=${() => {\n this.currentlyEditing = true;\n this.clearStatusMessaging();\n }}\n ><span>${this.plan?.nextBillingDateLocale}</span>\n </ia-mgc-form-section-info>`\n : nothing}\n ${this.currentlyEditing ? this.editDateForm : 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 dateUpdated(status: 'success' | 'fail') {\n this.clearInputField();\n\n this.updateStatus = status;\n this.updateMessage =\n status === 'success'\n ? 'Date updated'\n : 'Failed to update date, please try again';\n\n if (status === 'success') {\n this.closeForm();\n await this.updateComplete;\n return;\n }\n\n this.allowEditing = false;\n await this.updateComplete;\n }\n\n /* Dispatches edit-date change request */\n requestDateUpdate(e: Event): void {\n e.preventDefault();\n this.dispatchEvent(\n new CustomEvent('updateDate', {\n detail: {\n plan: this.plan,\n newDate: this.newDate,\n },\n })\n );\n }\n\n closeForm() {\n this.clearInputField();\n this.clearStatusMessaging();\n this.currentlyEditing = false;\n this.allowEditing = false;\n }\n\n clearInputField() {\n this.dateInput.value = '';\n this.newDate = undefined;\n }\n\n formatDateToYYYYMMDD(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\n const dateNum = String(date.getDate()).padStart(2, '0');\n return `${year}-${month}-${dateNum}`;\n }\n\n async clearStatusMessaging() {\n this.errorMessage = '';\n this.warningMessage = '';\n this.updateMessage = '';\n this.updateStatus = '';\n await this.updateComplete;\n }\n\n /* @param string dateString - YYYYY-MM-DD */\n validateChosenDate(dateString: string): {\n valid: boolean;\n errorCode: InvalidDateErrorCode | '';\n } {\n if (!dateString) {\n return {\n valid: false,\n errorCode: 'invalid_date',\n };\n }\n\n let validDate;\n try {\n validDate = new Date(`${dateString}T00:00:00`);\n } catch (error) {\n return {\n valid: false,\n errorCode: 'invalid_date',\n };\n }\n\n // Check if minimum date is at least tomorrow\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const tomorrow = new Date(today);\n tomorrow.setDate(today.getDate() + 1); // Set to tomorrow\n\n const chosenDate = new Date(validDate);\n chosenDate.setHours(0, 0, 0, 0);\n\n // check input value against next billing date\n const isNextBillingDate = this.plan?.nextBillingDate\n ? this.formatDateToYYYYMMDD(new Date(this.plan.nextBillingDate)) ===\n this.formatDateToYYYYMMDD(chosenDate)\n : false;\n if (isNextBillingDate) {\n return {\n valid: false,\n errorCode: 'same_next_billing_date',\n };\n }\n\n if (chosenDate < today) {\n return {\n valid: false,\n errorCode: 'date_too_early',\n };\n }\n\n // Check if the new date is within the next 12 months\n const twelveMonthsFromNow = new Date(today);\n twelveMonthsFromNow.setFullYear(twelveMonthsFromNow.getFullYear() + 1);\n\n if (chosenDate > twelveMonthsFromNow) {\n return {\n valid: false,\n errorCode: 'date_out_of_range',\n };\n }\n\n // Check if there has been a donation in the last month\n const lastDonationDate = this.plan?.payment.lastBillingDate.date\n ? new Date(this.plan?.payment.lastBillingDate.date)\n : null;\n\n if (lastDonationDate) {\n const lastDonationMonth = lastDonationDate.getMonth();\n const lastDonationYear = lastDonationDate.getFullYear();\n\n const thisYear = validDate.getFullYear();\n const thisMonth = validDate.getMonth();\n const isInLastMonth =\n thisYear === lastDonationYear && thisMonth === lastDonationMonth;\n\n if (isInLastMonth) {\n return {\n valid: true,\n errorCode: 'second_donation_this_month',\n };\n }\n }\n\n return {\n valid: true,\n errorCode: '',\n };\n }\n\n /* DISPLAY */\n get minDate(): string {\n const today = new Date();\n const tomorrow = new Date(today);\n tomorrow.setDate(today.getDate() + 1); // Set to tomorrow\n const year = tomorrow.getFullYear();\n const month = String(tomorrow.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\n const dateString = String(tomorrow.getDate()).padStart(2, '0');\n return `${year}-${month}-${dateString}`;\n }\n\n get maxDate(): string {\n const today = new Date();\n const year = today.getFullYear() + 1; // Allow up to one year in the future\n const month = String(today.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed\n const dateString = String(today.getDate()).padStart(2, '0');\n return `${year}-${month}-${dateString}`;\n }\n\n get editDateForm(): TemplateResult {\n const nextBillingDateYYYYMMDD = this.plan?.nextBillingDate\n ? this.formatDateToYYYYMMDD(new Date(this.plan.nextBillingDate))\n : '';\n const inputValueToUse = this.dateInput?.value ?? nextBillingDateYYYYMMDD;\n return html`\n <section>\n <form id=\"edit-date\">\n <p id=\"form-info-last-donation-date\">\n Last donation date: ${this.plan?.lastBillingDateLocale}\n </p>\n\n <p id=\"form-info-next-donation-date\">\n Next donation date: ${this.plan?.nextBillingDateLocale}\n </p>\n <div class=\"date-holder\">\n <input\n required\n type=\"date\"\n id=\"edit-date\"\n name=\"edit-date\"\n min=${this.minDate}\n max=${this.maxDate}\n .value=${inputValueToUse}\n @focus=${() => this.clearStatusMessaging()}\n @change=${async () => {\n this.clearStatusMessaging();\n await this.updateComplete;\n\n const inputValue = this.dateInput.value;\n const { valid, errorCode } =\n this.validateChosenDate(inputValue);\n\n this.allowEditing = valid;\n\n if (errorCode) {\n if (errorCode === 'second_donation_this_month') {\n this.errorMessage = InvalidDateErrorMessages[errorCode];\n this.warningMessage =\n 'You have already made a donation this month.';\n } else {\n this.errorMessage = InvalidDateErrorMessages[errorCode];\n this.newDate = undefined;\n return;\n }\n }\n\n const chosenDate = new Date(`${inputValue}T00:00:00`);\n const newDate = new Date(chosenDate).toISOString();\n this.newDate = newDate;\n }}\n />\n </div>\n <div>\n <div class=\"cta-container\">\n <ia-mgc-button\n class=\"ia-button secondary\"\n .clickHandler=${(e: Event) => {\n e.preventDefault();\n this.closeForm();\n }}\n >\n Cancel\n </ia-mgc-button>\n <ia-mgc-button\n id=\"edit-date\"\n class=\"ia-button primary\"\n type=\"submit\"\n .isDisabled=${!this.allowEditing}\n .clickHandler=${async (e: Event, iaButton: MGCButton) => {\n this.clearStatusMessaging();\n\n if (!this.newDate) {\n this.errorMessage = 'Please enter a valid date';\n return;\n }\n\n // eslint-disable-next-line no-param-reassign\n (iaButton as MGCButton).isDisabled = true;\n await iaButton.updateComplete;\n\n this.requestDateUpdate(e);\n }}\n >\n Update\n </ia-mgc-button>\n <ia-mgc-update-status .status=${this.updateStatus}\n >${this.updateMessage}</ia-mgc-update-status\n >\n </div>\n </div>\n <p class=\"error error-msg\">\n ${this.warningMessage\n ? html`<span>${this.warningMessage}</span><br />`\n : ''}\n ${this.errorMessage}\n </p>\n </form>\n </section>\n `;\n }\n\n static styles = css`\n input[name='edit-date'] {\n margin: 10px 0;\n min-width: 140px;\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"]}
@@ -117,7 +117,7 @@ let MonthlyGivingCircle = class MonthlyGivingCircle extends LitElement {
117
117
  title = 'Recent donations';
118
118
  titleStyle = 'default';
119
119
  cta = html `<ia-mgc-button
120
- class="link slim"
120
+ class="primary"
121
121
  id="close-receipts"
122
122
  .clickHandler=${async () => {
123
123
  this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';
@@ -1 +1 @@
1
- {"version":3,"file":"monthly-giving-circle.js","sourceRoot":"","sources":["../../src/monthly-giving-circle.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,E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AC;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;AAEiB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAiB;AAjBjD,mBAAmB;IAD/B,aAAa,CAAC,0BAA0B,CAAC;GAC7B,mBAAmB,CAsO/B;SAtOY,mBAAmB","sourcesContent":["import { 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/mgc-button';\nimport type { MonthlyPlan } from './models/plan';\nimport './edit-plan-form';\nimport type { IauxEditPlanForm } from './edit-plan-form';\n\nexport type APlanUpdate = {\n plan?: MonthlyPlan;\n donationId?: string;\n status: 'success' | 'fail';\n action: 'receiptSent' | 'cancel' | 'amountUpdate' | 'dateUpdate';\n message: string;\n};\n\nenum DisplayChangeEvents {\n welcome = 'ShowWelcome',\n receipts = 'ShowReceipts',\n plans = 'ShowPlans',\n editPlan = 'ShowEditForm',\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 @property({ type: Boolean, reflect: true }) canEdit = false;\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 get editFormElement(): IauxEditPlanForm {\n return this.querySelector('ia-mgc-edit-plan') as IauxEditPlanForm;\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\n if (update.action === 'amountUpdate') {\n this.editFormElement.amountUpdates(update.status);\n return;\n }\n\n if (update.action === 'dateUpdate') {\n this.editingThisPlan = plan;\n this.editFormElement.dateUpdates(update.status);\n return;\n }\n\n if (update.action === 'cancel' || 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 @cancelPlan=${() => {\n this.dispatchEvent(\n new CustomEvent('cancelPlan', {\n detail: { plan: this.editingThisPlan },\n })\n );\n }}\n .updateAmountHandler=${(\n plan: MonthlyPlan,\n options: {\n amount: number;\n baseAmount: number;\n coverFees: boolean;\n feeCovered: number;\n }\n ) => {\n console.log('updateAmount', plan, { ...options });\n this.dispatchEvent(\n new CustomEvent('updateAmount', {\n detail: { plan, amountOptions: options },\n })\n );\n }}\n @updateDate=${(event: CustomEvent) => {\n const { newDate } = event.detail;\n console.log('updateDate', newDate);\n this.dispatchEvent(\n new CustomEvent('updateDate', {\n detail: { plan: this.editingThisPlan, newDate },\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-mgc-button\n class=\"link slim\"\n .clickHandler=${async () => {\n this.viewToDisplay = 'receipts';\n await this.updateComplete;\n this.dispatchEvent(new Event(DisplayChangeEvents.receipts));\n }}\n >\n View recent donation history\n </ia-mgc-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-mgc-button\n class=\"link slim\"\n id=\"close-receipts\"\n .clickHandler=${async () => {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n const eventType = this.plans.length\n ? DisplayChangeEvents.plans\n : DisplayChangeEvents.welcome;\n this.dispatchEvent(new Event(eventType));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-mgc-button>`;\n break;\n\n case 'editPlan':\n title = 'Monthly Giving Circle';\n titleStyle = 'default';\n cta = html`<ia-mgc-button\n class=\"primary\"\n id=\"close-edit-plan\"\n .clickHandler=${async () => {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n const eventType = this.plans.length\n ? DisplayChangeEvents.plans\n : DisplayChangeEvents.welcome;\n this.dispatchEvent(new Event(eventType));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-mgc-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(DisplayChangeEvents.editPlan));\n await this.updateComplete;\n }}\n .plans=${this.plans}\n .canEdit=${this.canEdit}\n ></ia-mgc-plans>\n `\n : html`<ia-mgc-welcome\n .patronName=${this.patronName}\n ></ia-mgc-welcome>`}\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"monthly-giving-circle.js","sourceRoot":"","sources":["../../src/monthly-giving-circle.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,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,6BAA6B,CAAC;AAErC,OAAO,kBAAkB,CAAC;AAW1B,IAAK,mBAKJ;AALD,WAAK,mBAAmB;IACtB,8CAAuB,CAAA;IACvB,gDAAyB,CAAA;IACzB,0CAAmB,CAAA;IACnB,gDAAyB,CAAA;AAC3B,CAAC,EALI,mBAAmB,KAAnB,mBAAmB,QAKvB;AAGD,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAAnD;;QAC8B,eAAU,GAAW,EAAE,CAAC;QAEzB,aAAQ,GAAG,EAA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mB;IAD/B,aAAa,CAAC,0BAA0B,CAAC;GAC7B,mBAAmB,CAsO/B;SAtOY,mBAAmB","sourcesContent":["import { 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/mgc-button';\nimport type { MonthlyPlan } from './models/plan';\nimport './edit-plan-form';\nimport type { IauxEditPlanForm } from './edit-plan-form';\n\nexport type APlanUpdate = {\n plan?: MonthlyPlan;\n donationId?: string;\n status: 'success' | 'fail';\n action: 'receiptSent' | 'cancel' | 'amountUpdate' | 'dateUpdate';\n message: string;\n};\n\nenum DisplayChangeEvents {\n welcome = 'ShowWelcome',\n receipts = 'ShowReceipts',\n plans = 'ShowPlans',\n editPlan = 'ShowEditForm',\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 @property({ type: Boolean, reflect: true }) canEdit = false;\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 get editFormElement(): IauxEditPlanForm {\n return this.querySelector('ia-mgc-edit-plan') as IauxEditPlanForm;\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\n if (update.action === 'amountUpdate') {\n this.editFormElement.amountUpdates(update.status);\n return;\n }\n\n if (update.action === 'dateUpdate') {\n this.editingThisPlan = plan;\n this.editFormElement.dateUpdates(update.status);\n return;\n }\n\n if (update.action === 'cancel' || 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 @cancelPlan=${() => {\n this.dispatchEvent(\n new CustomEvent('cancelPlan', {\n detail: { plan: this.editingThisPlan },\n })\n );\n }}\n .updateAmountHandler=${(\n plan: MonthlyPlan,\n options: {\n amount: number;\n baseAmount: number;\n coverFees: boolean;\n feeCovered: number;\n }\n ) => {\n console.log('updateAmount', plan, { ...options });\n this.dispatchEvent(\n new CustomEvent('updateAmount', {\n detail: { plan, amountOptions: options },\n })\n );\n }}\n @updateDate=${(event: CustomEvent) => {\n const { newDate } = event.detail;\n console.log('updateDate', newDate);\n this.dispatchEvent(\n new CustomEvent('updateDate', {\n detail: { plan: this.editingThisPlan, newDate },\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-mgc-button\n class=\"link slim\"\n .clickHandler=${async () => {\n this.viewToDisplay = 'receipts';\n await this.updateComplete;\n this.dispatchEvent(new Event(DisplayChangeEvents.receipts));\n }}\n >\n View recent donation history\n </ia-mgc-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-mgc-button\n class=\"primary\"\n id=\"close-receipts\"\n .clickHandler=${async () => {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n const eventType = this.plans.length\n ? DisplayChangeEvents.plans\n : DisplayChangeEvents.welcome;\n this.dispatchEvent(new Event(eventType));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-mgc-button>`;\n break;\n\n case 'editPlan':\n title = 'Monthly Giving Circle';\n titleStyle = 'default';\n cta = html`<ia-mgc-button\n class=\"primary\"\n id=\"close-edit-plan\"\n .clickHandler=${async () => {\n this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';\n const eventType = this.plans.length\n ? DisplayChangeEvents.plans\n : DisplayChangeEvents.welcome;\n this.dispatchEvent(new Event(eventType));\n this.updates = [];\n await this.updateComplete;\n }}\n >\n Back to account settings\n </ia-mgc-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(DisplayChangeEvents.editPlan));\n await this.updateComplete;\n }}\n .plans=${this.plans}\n .canEdit=${this.canEdit}\n ></ia-mgc-plans>\n `\n : html`<ia-mgc-welcome\n .patronName=${this.patronName}\n ></ia-mgc-welcome>`}\n `;\n }\n}\n"]}
package/dist/src/plans.js CHANGED
@@ -106,7 +106,7 @@ let IauxMgcPlans = class IauxMgcPlans extends LitElement {
106
106
  IauxMgcPlans.styles = css `
107
107
  :host {
108
108
  max-height: 500px;
109
- overflow-y: scroll;
109
+ overflow-y: auto;
110
110
  display: block;
111
111
  }
112
112
 
@@ -1 +1 @@
1
- {"version":3,"file":"plans.js","sourceRoot":"","sources":["../../src/plans.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,6BAA6B,CAAC;AAIrC,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QAC6B,UAAK,GAAG,EAAE,CAAC;QAEM,YAAO,GAAG,KAAK,CAAC;IA+L9D,CAAC;IA7LW,MAAM;QACd,OAAO,IAAI,CAAA;;;YAGH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAiB,EAAE,EAAE;;YACrC,IAAI,UAAU,GACZ,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,iBAAiB,mCAAI,kBAAkB,CAAC;YACxD,IAAI,UAAU,KAAK,YAAY,EAAE;gBAC/B,UAAU,GAAG,aAAa,CAAC;aAC5B;YACD,MAAM,QAAQ,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,mCAAI,qBAAqB,CAAC;YACjE,MAAM,KAAK,GAAG,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK;gBAC/B,CAAC,CAAC,MAAM,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,EAAE;gBAC7B,CAAC,CAAC,qBAAqB,CAAC;YAE1B,OAAO,IAAI,CAAA;0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IAAI,CAAC;;aAEvB,CAAC;QACJ,CAAC,CAAC;;;KAGP,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,UAAU,GAAG,6EAA6E,CAAC;YACjG,OAAO,IAAI,CAAA;;kBAEC,UAAU;WACjB,CAAC;SACP;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW;YACnC,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,8BAA8B,CAAC;QAEnC,OAAO,IAAI,CAAA;;oBAEK,IAAI,CAAC,IAAI,CAAC,WAAW;sBACnB,KAAK,EAAE,CAAQ,EAAE,QAAmB,EAAE,EAAE;YACtD,iBAAiB;YACjB,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;YAC3B,YAAY;YACZ,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CACtD,CAAC;QACJ,CAAC;SACE,OAAO;MACV,CAAC;IACL,CAAC;CAyFF,CAAA;AAvFQ,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFlB,CAAC;AAhMyB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CAAY;AAEM;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAiB;AAHjD,YAAY;IADxB,aAAa,CAAC,cAAc,CAAC;GACjB,YAAY,CAkMxB;SAlMY,YAAY","sourcesContent":["/* eslint-disable no-param-reassign */\nimport { LitElement, html, css, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport type { MonthlyPlan } from './models/plan';\n\nimport './presentational/mgc-button';\nimport type { MGCButton } from './presentational/mgc-button';\n\n@customElement('ia-mgc-plans')\nexport class IauxMgcPlans extends LitElement {\n @property({ type: Array }) plans = [];\n\n @property({ type: Boolean, reflect: true }) canEdit = false;\n\n protected render() {\n return html`\n <section class=\"monthly-giving-circle\">\n <ul>\n ${this.plans.map((plan: MonthlyPlan) => {\n let methodType =\n plan.payment?.paymentMethodType ?? 'Method not found';\n if (methodType === 'creditCard') {\n methodType = 'Credit card';\n }\n const cardType = plan.payment?.cardType ?? 'Card type not found';\n const last4 = plan.payment?.last4\n ? `...${plan.payment?.last4}`\n : 'CC number not found';\n\n return html`\n <li class=${`${plan.plan.isCancelled ? 'cancelled' : ''}`}>\n <div class=\"info\">\n <div class=\"amount\">\n <h3>Amount</h3>\n <p>\n ${plan.currency}\n ${plan.currencySymbol}${plan.amount}/month\n </p>\n ${plan.isTest\n ? html`<p class=\"is-test\">(Test payment)</p>`\n : nothing}\n </div>\n <div class=\"payment-details\">\n <h3>Method</h3>\n <p>${methodType}</p>\n ${plan.payment?.paymentMethodType === 'creditCard'\n ? html`<p>${cardType}</p>\n <p>${last4}</p>`\n : nothing}\n ${plan.payment?.paymentMethodType === 'Paypal'\n ? html`<p>\n Paypal email:\n <a href=${`mailto:${plan.payment?.paypalEmail}`}\n >${plan.payment?.paypalEmail}</a\n >\n </p>`\n : nothing}\n ${plan.payment?.paymentMethodType === 'Venmo'\n ? html`<p>\n Venmo username:\n <a href=${`mailto:${plan.payment?.venmoUsername}`}\n >${plan.payment?.paypalEmail}</a\n >\n </p>`\n : nothing}\n ${plan.payment?.paymentMethodType !== 'creditCard'\n ? html`<p>\n Expires:\n ${plan.payment?.expirationMonth ??\n 'month not found'}/${plan.payment?.expirationYear ??\n 'year not found'}\n </p>`\n : nothing}\n </div>\n <div class=\"next-donation\">\n <h3>Next Donation</h3>\n <p>${plan.nextBillingDateLocale}</p>\n </div>\n </div>\n ${this.planCTA(plan)}\n </li>\n `;\n })}\n </ul>\n </section>\n `;\n }\n\n planCTA(plan: MonthlyPlan) {\n if (!this.canEdit) {\n const mailToText = `mailto:donations@archive.org?subject=I'd like to update my monthly donation`;\n return html`<p class=\"email-edit-plan\">\n Need to update your plan further? Please email us at\n <a href=${mailToText}>donations@archive.org</a>.\n </p>`;\n }\n\n const ctaText = plan.plan.isCancelled\n ? 'Plan is cancelled'\n : 'Manage this monthly donation';\n\n return html`<ia-mgc-button\n class=\"ia-button link edit-donation\"\n .isDisabled=${plan.plan.isCancelled}\n .clickHandler=${async (e: Event, iaButton: MGCButton) => {\n // disable button\n iaButton.isDisabled = true;\n // open form\n this.dispatchEvent(\n new CustomEvent('editThisPlan', { detail: { plan } })\n );\n }}\n >${ctaText}</ia-mgc-button\n >`;\n }\n\n static styles = css`\n :host {\n max-height: 500px;\n overflow-y: scroll;\n display: block;\n }\n\n .is-test {\n font-size: 0.8rem;\n }\n\n li {\n border: 1px solid #23765d;\n background-color: #eeffee;\n display: block;\n width: inherit;\n }\n li.cancelled {\n background-color: lightgoldenrodyellow;\n }\n table {\n width: 100%;\n text-align: left;\n max-width: 600px;\n }\n\n ul {\n padding: 0;\n list-style-type: none;\n margin: 0;\n }\n\n ul li {\n border: 1px solid #23765d;\n background-color: #eeffee;\n margin: 0.5rem 0;\n padding: 0.5rem 0.5rem 1rem 0.5rem;\n position: relative;\n }\n\n ul li button.edit-donation {\n height: 30px;\n display: block;\n position: absolute;\n bottom: 0;\n }\n\n ul li .info {\n display: grid;\n min-height: 90px;\n grid-template-columns: 0.5fr 1fr 0.5fr;\n grid-template-rows: 1fr;\n gap: 0px 5px;\n grid-auto-flow: row;\n grid-template-areas: 'amount details next-donation';\n }\n\n ul li .info .amount {\n grid-area: amount;\n }\n\n ul li .info .payment-details {\n grid-area: details;\n }\n\n ul li .info .next-donation {\n grid-area: next-donation;\n }\n\n ul li .info > * {\n margin: 0 0 0.5rem 0;\n }\n\n ul li .info > * > * {\n margin: 0;\n }\n\n .email-edit-plan {\n margin-bottom: 0;\n }\n\n @media screen and (max-width: 500px) {\n ul li .info {\n display: block;\n }\n }\n `;\n}\n"]}
1
+ {"version":3,"file":"plans.js","sourceRoot":"","sources":["../../src/plans.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,6BAA6B,CAAC;AAIrC,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QAC6B,UAAK,GAAG,EAAE,CAAC;QAEM,YAAO,GAAG,KAAK,CAAC;IA+L9D,CAAC;IA7LW,MAAM;QACd,OAAO,IAAI,CAAA;;;YAGH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAiB,EAAE,EAAE;;YACrC,IAAI,UAAU,GACZ,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,iBAAiB,mCAAI,kBAAkB,CAAC;YACxD,IAAI,UAAU,KAAK,YAAY,EAAE;gBAC/B,UAAU,GAAG,aAAa,CAAC;aAC5B;YACD,MAAM,QAAQ,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,mCAAI,qBAAqB,CAAC;YACjE,MAAM,KAAK,GAAG,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK;gBAC/B,CAAC,CAAC,MAAM,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,EAAE;gBAC7B,CAAC,CAAC,qBAAqB,CAAC;YAE1B,OAAO,IAAI,CAAA;0BACG,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;;;;;wBAK/C,IAAI,CAAC,QAAQ;wBACb,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM;;sBAEnC,IAAI,CAAC,MAAM;gBACX,CAAC,CAAC,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AAC;SACP;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW;YACnC,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,8BAA8B,CAAC;QAEnC,OAAO,IAAI,CAAA;;oBAEK,IAAI,CAAC,IAAI,CAAC,WAAW;sBACnB,KAAK,EAAE,CAAQ,EAAE,QAAmB,EAAE,EAAE;YACtD,iBAAiB;YACjB,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;YAC3B,YAAY;YACZ,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CACtD,CAAC;QACJ,CAAC;SACE,OAAO;MACV,CAAC;IACL,CAAC;CAyFF,CAAA;AAvFQ,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFlB,CAAC;AAhMyB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CAAY;AAEM;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAAiB;AAHjD,YAAY;IADxB,aAAa,CAAC,cAAc,CAAC;GACjB,YAAY,CAkMxB;SAlMY,YAAY","sourcesContent":["/* eslint-disable no-param-reassign */\nimport { LitElement, html, css, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport type { MonthlyPlan } from './models/plan';\n\nimport './presentational/mgc-button';\nimport type { MGCButton } from './presentational/mgc-button';\n\n@customElement('ia-mgc-plans')\nexport class IauxMgcPlans extends LitElement {\n @property({ type: Array }) plans = [];\n\n @property({ type: Boolean, reflect: true }) canEdit = false;\n\n protected render() {\n return html`\n <section class=\"monthly-giving-circle\">\n <ul>\n ${this.plans.map((plan: MonthlyPlan) => {\n let methodType =\n plan.payment?.paymentMethodType ?? 'Method not found';\n if (methodType === 'creditCard') {\n methodType = 'Credit card';\n }\n const cardType = plan.payment?.cardType ?? 'Card type not found';\n const last4 = plan.payment?.last4\n ? `...${plan.payment?.last4}`\n : 'CC number not found';\n\n return html`\n <li class=${`${plan.plan.isCancelled ? 'cancelled' : ''}`}>\n <div class=\"info\">\n <div class=\"amount\">\n <h3>Amount</h3>\n <p>\n ${plan.currency}\n ${plan.currencySymbol}${plan.amount}/month\n </p>\n ${plan.isTest\n ? html`<p class=\"is-test\">(Test payment)</p>`\n : nothing}\n </div>\n <div class=\"payment-details\">\n <h3>Method</h3>\n <p>${methodType}</p>\n ${plan.payment?.paymentMethodType === 'creditCard'\n ? html`<p>${cardType}</p>\n <p>${last4}</p>`\n : nothing}\n ${plan.payment?.paymentMethodType === 'Paypal'\n ? html`<p>\n Paypal email:\n <a href=${`mailto:${plan.payment?.paypalEmail}`}\n >${plan.payment?.paypalEmail}</a\n >\n </p>`\n : nothing}\n ${plan.payment?.paymentMethodType === 'Venmo'\n ? html`<p>\n Venmo username:\n <a href=${`mailto:${plan.payment?.venmoUsername}`}\n >${plan.payment?.paypalEmail}</a\n >\n </p>`\n : nothing}\n ${plan.payment?.paymentMethodType !== 'creditCard'\n ? html`<p>\n Expires:\n ${plan.payment?.expirationMonth ??\n 'month not found'}/${plan.payment?.expirationYear ??\n 'year not found'}\n </p>`\n : nothing}\n </div>\n <div class=\"next-donation\">\n <h3>Next Donation</h3>\n <p>${plan.nextBillingDateLocale}</p>\n </div>\n </div>\n ${this.planCTA(plan)}\n </li>\n `;\n })}\n </ul>\n </section>\n `;\n }\n\n planCTA(plan: MonthlyPlan) {\n if (!this.canEdit) {\n const mailToText = `mailto:donations@archive.org?subject=I'd like to update my monthly donation`;\n return html`<p class=\"email-edit-plan\">\n Need to update your plan further? Please email us at\n <a href=${mailToText}>donations@archive.org</a>.\n </p>`;\n }\n\n const ctaText = plan.plan.isCancelled\n ? 'Plan is cancelled'\n : 'Manage this monthly donation';\n\n return html`<ia-mgc-button\n class=\"ia-button link edit-donation\"\n .isDisabled=${plan.plan.isCancelled}\n .clickHandler=${async (e: Event, iaButton: MGCButton) => {\n // disable button\n iaButton.isDisabled = true;\n // open form\n this.dispatchEvent(\n new CustomEvent('editThisPlan', { detail: { plan } })\n );\n }}\n >${ctaText}</ia-mgc-button\n >`;\n }\n\n static styles = css`\n :host {\n max-height: 500px;\n overflow-y: auto;\n display: block;\n }\n\n .is-test {\n font-size: 0.8rem;\n }\n\n li {\n border: 1px solid #23765d;\n background-color: #eeffee;\n display: block;\n width: inherit;\n }\n li.cancelled {\n background-color: lightgoldenrodyellow;\n }\n table {\n width: 100%;\n text-align: left;\n max-width: 600px;\n }\n\n ul {\n padding: 0;\n list-style-type: none;\n margin: 0;\n }\n\n ul li {\n border: 1px solid #23765d;\n background-color: #eeffee;\n margin: 0.5rem 0;\n padding: 0.5rem 0.5rem 1rem 0.5rem;\n position: relative;\n }\n\n ul li button.edit-donation {\n height: 30px;\n display: block;\n position: absolute;\n bottom: 0;\n }\n\n ul li .info {\n display: grid;\n min-height: 90px;\n grid-template-columns: 0.5fr 1fr 0.5fr;\n grid-template-rows: 1fr;\n gap: 0px 5px;\n grid-auto-flow: row;\n grid-template-areas: 'amount details next-donation';\n }\n\n ul li .info .amount {\n grid-area: amount;\n }\n\n ul li .info .payment-details {\n grid-area: details;\n }\n\n ul li .info .next-donation {\n grid-area: next-donation;\n }\n\n ul li .info > * {\n margin: 0 0 0.5rem 0;\n }\n\n ul li .info > * > * {\n margin: 0;\n }\n\n .email-edit-plan {\n margin-bottom: 0;\n }\n\n @media screen and (max-width: 500px) {\n ul li .info {\n display: block;\n }\n }\n `;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { LitElement } from 'lit';
2
+ import './mgc-button';
3
+ export declare class MGCFormSectionInfo extends LitElement {
4
+ protected render(): import("lit").TemplateResult<1>;
5
+ }
@@ -0,0 +1,28 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html } from 'lit';
3
+ import { customElement } from 'lit/decorators.js';
4
+ import './mgc-button';
5
+ let MGCFormSectionInfo = class MGCFormSectionInfo extends LitElement {
6
+ render() {
7
+ return html `
8
+ <div class="mgc-donation-section-info">
9
+ <p><slot></slot></p>
10
+ <ia-mgc-button
11
+ class="ia-button link"
12
+ .clickHandler=${(_event, iaButton) => {
13
+ // eslint-disable-next-line no-param-reassign
14
+ iaButton.isDisabled = true;
15
+ this.dispatchEvent(new Event('editingRequested'));
16
+ }}
17
+ >
18
+ Edit...
19
+ </ia-mgc-button>
20
+ </div>
21
+ `;
22
+ }
23
+ };
24
+ MGCFormSectionInfo = __decorate([
25
+ customElement('ia-mgc-form-section-info')
26
+ ], MGCFormSectionInfo);
27
+ export { MGCFormSectionInfo };
28
+ //# sourceMappingURL=donation-section-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"donation-section-info.js","sourceRoot":"","sources":["../../../src/presentational/donation-section-info.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,cAAc,CAAC;AAItB,IAAa,kBAAkB,GAA/B,MAAa,kBAAmB,SAAQ,UAAU;IACtC,MAAM;QACd,OAAO,IAAI,CAAA;;;;;0BAKW,CAAC,MAAa,EAAE,QAAmB,EAAE,EAAE;YACrD,6CAA6C;YAC7C,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpD,CAAC;;;;;KAKN,CAAC;IACJ,CAAC;CACF,CAAA;AAlBY,kBAAkB;IAD9B,aAAa,CAAC,0BAA0B,CAAC;GAC7B,kBAAkB,CAkB9B;SAlBY,kBAAkB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport './mgc-button';\nimport type { MGCButton } from './mgc-button';\n\n@customElement('ia-mgc-form-section-info')\nexport class MGCFormSectionInfo extends LitElement {\n protected render() {\n return html`\n <div class=\"mgc-donation-section-info\">\n <p><slot></slot></p>\n <ia-mgc-button\n class=\"ia-button link\"\n .clickHandler=${(_event: Event, iaButton: MGCButton) => {\n // eslint-disable-next-line no-param-reassign\n iaButton.isDisabled = true;\n this.dispatchEvent(new Event('editingRequested'));\n }}\n >\n Edit...\n </ia-mgc-button>\n </div>\n `;\n }\n}\n"]}
@@ -30,6 +30,7 @@ MGCTitle.styles = css `
30
30
  :host {
31
31
  padding-bottom: 5px;
32
32
  display: block;
33
+ --link-button-padding: 0.5rem;
33
34
  }
34
35
 
35
36
  :host([titlestyle='default']) h2 {
@@ -50,7 +51,7 @@ MGCTitle.styles = css `
50
51
  align-content: center;
51
52
  margin: 0;
52
53
  justify-content: space-between;
53
- align-items: flex-end;
54
+ align-items: center;
54
55
  line-height: normal;
55
56
  }
56
57
 
@@ -76,6 +77,10 @@ MGCTitle.styles = css `
76
77
  align-items: flex-end;
77
78
  }
78
79
 
80
+ ia-mgc-button {
81
+ --link-button-padding: 0.5rem;
82
+ }
83
+
79
84
  @media screen and (max-width: 450px) {
80
85
  h2,
81
86
  slot[name='action'] {
@@ -1 +1 @@
1
- {"version":3,"file":"mgc-title.js","sourceRoot":"","sources":["../../../src/presentational/mgc-title.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,6CAA6C,CAAC;AAGrD,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,UAAU;IAAxC;;QAC8B,eAAU,GAAwB,OAAO,CAAC;IAkFxE,CAAC;IAhFC,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,UAAU,KAAK,OAAO;YAChC,CAAC,CAAC,IAAI,CAAA,oEAAoE;YAC1E,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;cAID,IAAI,CAAC,KAAK;;;;;;KAMnB,CAAC;IACJ,CAAC;CA8DF,CAAA;AA5DQ,eAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DlB,CAAC;AAjF0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA2C;AAD3D,QAAQ;IADpB,aAAa,CAAC,cAAc,CAAC;GACjB,QAAQ,CAmFpB;SAnFY,QAAQ","sourcesContent":["import { LitElement, html, css, TemplateResult, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport '@internetarchive/icon-donate/icon-donate.js';\n\n@customElement('ia-mgc-title')\nexport class MGCTitle extends LitElement {\n @property({ type: String }) titleStyle: 'heart' | 'default' = 'heart';\n\n get heart(): TemplateResult | typeof nothing {\n return this.titleStyle === 'heart'\n ? html` <div class=\"icon-donate\"><ia-icon-donate></ia-icon-donate></div> `\n : nothing;\n }\n\n render() {\n return html`\n <div>\n <h2>\n <div class=\"title-section\">\n ${this.heart}\n <slot name=\"title\"></slot>\n </div>\n <slot name=\"action\"></slot>\n </h2>\n </div>\n `;\n }\n\n static styles = css`\n :host {\n padding-bottom: 5px;\n display: block;\n }\n\n :host([titlestyle='default']) h2 {\n justify-content: flex-start;\n gap: 20px;\n }\n\n :host([titlestyle='heart']) h2 .title-section {\n width: 100%;\n display: flex;\n }\n\n h2 {\n font-size: 1.5em;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-content: center;\n margin: 0;\n justify-content: space-between;\n align-items: flex-end;\n line-height: normal;\n }\n\n h2 .icon-donate {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-content: flex-end;\n align-items: center;\n justify-content: flex-start;\n }\n\n h2 .icon-donate {\n --iconFillColor: red;\n --iconWidth: 1.2em;\n --iconHeight: 1.2em;\n }\n\n slot[name='action'] {\n padding: 0 !important;\n display: flex;\n justify-content: flex-end;\n align-items: flex-end;\n }\n\n @media screen and (max-width: 450px) {\n h2,\n slot[name='action'] {\n display: block;\n }\n slot[name='action'] {\n margin-top: 10px;\n }\n }\n `;\n}\n"]}
1
+ {"version":3,"file":"mgc-title.js","sourceRoot":"","sources":["../../../src/presentational/mgc-title.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,6CAA6C,CAAC;AAGrD,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,UAAU;IAAxC;;QAC8B,eAAU,GAAwB,OAAO,CAAC;IAuFxE,CAAC;IArFC,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,UAAU,KAAK,OAAO;YAChC,CAAC,CAAC,IAAI,CAAA,oEAAoE;YAC1E,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;cAID,IAAI,CAAC,KAAK;;;;;;KAMnB,CAAC;IACJ,CAAC;CAmEF,CAAA;AAjEQ,eAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgElB,CAAC;AAtF0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA2C;AAD3D,QAAQ;IADpB,aAAa,CAAC,cAAc,CAAC;GACjB,QAAQ,CAwFpB;SAxFY,QAAQ","sourcesContent":["import { LitElement, html, css, TemplateResult, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport '@internetarchive/icon-donate/icon-donate.js';\n\n@customElement('ia-mgc-title')\nexport class MGCTitle extends LitElement {\n @property({ type: String }) titleStyle: 'heart' | 'default' = 'heart';\n\n get heart(): TemplateResult | typeof nothing {\n return this.titleStyle === 'heart'\n ? html` <div class=\"icon-donate\"><ia-icon-donate></ia-icon-donate></div> `\n : nothing;\n }\n\n render() {\n return html`\n <div>\n <h2>\n <div class=\"title-section\">\n ${this.heart}\n <slot name=\"title\"></slot>\n </div>\n <slot name=\"action\"></slot>\n </h2>\n </div>\n `;\n }\n\n static styles = css`\n :host {\n padding-bottom: 5px;\n display: block;\n --link-button-padding: 0.5rem;\n }\n\n :host([titlestyle='default']) h2 {\n justify-content: flex-start;\n gap: 20px;\n }\n\n :host([titlestyle='heart']) h2 .title-section {\n width: 100%;\n display: flex;\n }\n\n h2 {\n font-size: 1.5em;\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-content: center;\n margin: 0;\n justify-content: space-between;\n align-items: center;\n line-height: normal;\n }\n\n h2 .icon-donate {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-content: flex-end;\n align-items: center;\n justify-content: flex-start;\n }\n\n h2 .icon-donate {\n --iconFillColor: red;\n --iconWidth: 1.2em;\n --iconHeight: 1.2em;\n }\n\n slot[name='action'] {\n padding: 0 !important;\n display: flex;\n justify-content: flex-end;\n align-items: flex-end;\n }\n\n ia-mgc-button {\n --link-button-padding: 0.5rem;\n }\n\n @media screen and (max-width: 450px) {\n h2,\n slot[name='action'] {\n display: block;\n }\n slot[name='action'] {\n margin-top: 10px;\n }\n }\n `;\n}\n"]}
@@ -32,10 +32,10 @@ describe('<ia-mgc-edit-plan-amount>', () => {
32
32
  it('displays with call to edit', async () => {
33
33
  var _a, _b;
34
34
  const el = await fixture(html `<ia-mgc-edit-plan-amount .plan=${plan}></ia-mgc-edit-plan-amount>`);
35
- const amountLabel = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.current-amount');
36
- expect(amountLabel).to.exist;
37
- expect(amountLabel === null || amountLabel === void 0 ? void 0 : amountLabel.textContent).to.contain('$5');
38
- const cta = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('ia-mgc-button#edit-amount');
35
+ const holder = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ia-mgc-form-section-info');
36
+ expect(holder).to.exist;
37
+ expect(holder === null || holder === void 0 ? void 0 : holder.textContent).to.contain('$5');
38
+ const cta = (_b = holder === null || holder === void 0 ? void 0 : holder.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('ia-mgc-button');
39
39
  expect(cta).to.exist;
40
40
  // do not show form
41
41
  expect(el.form).to.not.exist;
@@ -1 +1 @@
1
- {"version":3,"file":"amount.test.js","sourceRoot":"","sources":["../../../test/form-sections/amount.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,gCAAgC,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC;IAC3B,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;IACf,UAAU,EAAE,qBAAqB;IACjC,OAAO,EAAE,IAAI;IACb,MAAM,EAAE;QACN,iBAAiB,EAAE,EAAE;QACrB,eAAe,EAAE;YACf,IAAI,EAAE,4BAA4B;YAClC,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,KAAK;SAChB;QACD,eAAe,EAAE;YACf,IAAI,EAAE,4BAA4B;YAClC,aAAa,EAAE,CAAC;YAChB,QAAQ,EAAE,KAAK;SAChB;QACD,MAAM,EAAE,QAAQ;QAChB,iBAAiB,EAAE,OAAO;QAC1B,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,IAAI;QACd,eAAe,EAAE,IAAI;QACrB,cAAc,EAAE,IAAI;KACrB;CACF,CAAC,CAAC;AAEH,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;;QAC1C,MAAM,EAAE,GAAG,MAAM,OAAO,CACtB,IAAI,CAAA,kCAAkC,IAAI,6BAA6B,CACxE,CAAC;QAEF,MAAM,WAAW,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;QACpE,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,MAAM,CAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAElD,MAAM,GAAG,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;QACtE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAErB,mBAAmB;QACnB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;QAE7B,GAAI,CAAC,UAAW,CAAC,aAAa,CAAC,QAAQ,CAAE,CAAC,KAAK,EAAE,CAAC;QAClD,MAAM,EAAE,CAAC,cAAc,CAAC;QAExB,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAEvD,oBAAoB;QACpB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport { html, fixture, expect } from '@open-wc/testing';\n\nimport '../../src/form-sections/amount';\nimport type { MGCEditPlanAmount } from '../../src/form-sections/amount';\nimport { MonthlyPlan } from '../../src/models/plan';\n\nconst plan = new MonthlyPlan({\n token: 'a.va.lid.T0ken',\n amount: 5,\n currency: 'USD',\n start_date: '2024-07-01 00:00:00',\n is_test: true,\n btdata: {\n billingDayOfMonth: 22,\n nextBillingDate: {\n date: '2024-08-22 00:00:00.000000',\n timezone_type: 3,\n timezone: 'UTC',\n },\n lastBillingDate: {\n date: '2024-07-22 00:00:00.000000',\n timezone_type: 3,\n timezone: 'UTC',\n },\n status: 'Active',\n paymentMethodType: 'Venmo',\n last4: null,\n cardType: null,\n expirationMonth: null,\n expirationYear: null,\n },\n});\n\ndescribe('<ia-mgc-edit-plan-amount>', () => {\n it('displays with call to edit', async () => {\n const el = await fixture<MGCEditPlanAmount>(\n html`<ia-mgc-edit-plan-amount .plan=${plan}></ia-mgc-edit-plan-amount>`\n );\n\n const amountLabel = el.shadowRoot?.querySelector('.current-amount');\n expect(amountLabel).to.exist;\n expect(amountLabel?.textContent).to.contain('$5');\n\n const cta = el.shadowRoot?.querySelector('ia-mgc-button#edit-amount');\n expect(cta).to.exist;\n\n // do not show form\n expect(el.form).to.not.exist;\n\n cta!.shadowRoot!.querySelector('button')!.click();\n await el.updateComplete;\n\n expect(el.hasAttribute('currentlyediting')).to.be.true;\n\n // form now displays\n expect(el.form.getAttribute('id')).to.equal('edit-plan-amount');\n });\n});\n"]}
1
+ {"version":3,"file":"amount.test.js","sourceRoot":"","sources":["../../../test/form-sections/amount.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,gCAAgC,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC;IAC3B,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;IAC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E,CAAC,KAAK,EAAE,CAAC;QAClD,MAAM,EAAE,CAAC,cAAc,CAAC;QAExB,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAEvD,oBAAoB;QACpB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport { html, fixture, expect } from '@open-wc/testing';\n\nimport '../../src/form-sections/amount';\nimport type { MGCEditPlanAmount } from '../../src/form-sections/amount';\nimport { MonthlyPlan } from '../../src/models/plan';\n\nconst plan = new MonthlyPlan({\n token: 'a.va.lid.T0ken',\n amount: 5,\n currency: 'USD',\n start_date: '2024-07-01 00:00:00',\n is_test: true,\n btdata: {\n billingDayOfMonth: 22,\n nextBillingDate: {\n date: '2024-08-22 00:00:00.000000',\n timezone_type: 3,\n timezone: 'UTC',\n },\n lastBillingDate: {\n date: '2024-07-22 00:00:00.000000',\n timezone_type: 3,\n timezone: 'UTC',\n },\n status: 'Active',\n paymentMethodType: 'Venmo',\n last4: null,\n cardType: null,\n expirationMonth: null,\n expirationYear: null,\n },\n});\n\ndescribe('<ia-mgc-edit-plan-amount>', () => {\n it('displays with call to edit', async () => {\n const el = await fixture<MGCEditPlanAmount>(\n html`<ia-mgc-edit-plan-amount .plan=${plan}></ia-mgc-edit-plan-amount>`\n );\n\n const holder = el.shadowRoot?.querySelector('ia-mgc-form-section-info');\n expect(holder).to.exist;\n expect(holder?.textContent).to.contain('$5');\n\n const cta = holder?.shadowRoot?.querySelector('ia-mgc-button');\n expect(cta).to.exist;\n\n // do not show form\n expect(el.form).to.not.exist;\n\n cta!.shadowRoot!.querySelector('button')!.click();\n await el.updateComplete;\n\n expect(el.hasAttribute('currentlyediting')).to.be.true;\n\n // form now displays\n expect(el.form.getAttribute('id')).to.equal('edit-plan-amount');\n });\n});\n"]}
@@ -55,10 +55,10 @@ describe('<ia-mgc-edit-date>', () => {
55
55
  it('input validates before allowing form submission', async () => {
56
56
  var _a, _b, _c, _d;
57
57
  const el = await fixture(html `<ia-mgc-edit-date .plan=${plan}></ia-mgc-edit-date>`);
58
- const amountLabel = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.current-date');
59
- expect(amountLabel).to.exist;
60
- expect(amountLabel === null || amountLabel === void 0 ? void 0 : amountLabel.textContent).to.contain(plan.nextBillingDateLocale);
61
- const cta = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('ia-mgc-button#open-edit-date-form');
58
+ const holder = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('ia-mgc-form-section-info');
59
+ expect(holder).to.equal(3);
60
+ expect(holder === null || holder === void 0 ? void 0 : holder.textContent).to.contain(plan.nextBillingDateLocale);
61
+ const cta = (_b = holder === null || holder === void 0 ? void 0 : holder.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('ia-mgc-button');
62
62
  expect(cta).to.exist;
63
63
  // does not show form
64
64
  expect(el.form).to.not.exist;
@@ -1 +1 @@
1
- {"version":3,"file":"date.test.js","sourceRoot":"","sources":["../../../test/form-sections/date.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,MAAM,mCAAmC,GAAG,IAAI,IAAI,EAAE,CAAC;AACvD,mCAAmC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzD,mCAAmC,CAAC,OAAO,CAAC,CAAC,CAAC,CAA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,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,MAAA,MAAA,uBAAuB,CAAC,UAAU,0CAAE,aAAa,CAAC,QAAQ,CAAC,0CAAE,KAAK,EAAE,CAAC;QACrE,MAAM,EAAE,CAAC,cAAc,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport { html, fixture, expect } from '@open-wc/testing';\n\nimport '../../src/form-sections/date';\nimport type { MGCEditPlanDate } from '../../src/form-sections/date';\nimport { MonthlyPlan } from '../../src/models/plan';\nimport type { MGCButton } from '../../src/presentational/mgc-button';\n\nconst lastPaymentWasOnTheFirstOfThisMonth = new Date();\nlastPaymentWasOnTheFirstOfThisMonth.setHours(0, 0, 0, 0);\nlastPaymentWasOnTheFirstOfThisMonth.setDate(1);\nconsole.log(\n 'lastPaymentWasOnTheFirstOfThisMonth',\n lastPaymentWasOnTheFirstOfThisMonth.toISOString()\n);\n\nconst nextMonth = new Date();\nnextMonth.setMonth(nextMonth.getMonth() + 1);\n\nconst nextPaymentFirstOfMonth = new Date(nextMonth);\nnextPaymentFirstOfMonth.setHours(0, 0, 0, 0);\nnextPaymentFirstOfMonth.setDate(1);\nconsole.log('nextPaymentFirstOfMonth', nextPaymentFirstOfMonth.toISOString());\n\nconst twelveMonthsFromNow = new Date();\ntwelveMonthsFromNow.setMonth(twelveMonthsFromNow.getMonth() + 12);\n\nconst twoYearsFromNow = new Date();\ntwoYearsFromNow.setFullYear(twoYearsFromNow.getFullYear() + 2);\ntwoYearsFromNow.setHours(0, 0, 0, 0);\n\nconst tomorrow = new Date();\ntomorrow.setDate(tomorrow.getDate() + 1);\n\nconst today = new Date();\ntoday.setHours(0, 0, 0, 0);\n\nconst yesterday = new Date();\nyesterday.setDate(yesterday.getDate() - 1);\nyesterday.setHours(0, 0, 0, 0);\n\nconst plan = new MonthlyPlan({\n token: 'a.va.lid.T0ken',\n amount: 5,\n currency: 'USD',\n start_date: '2024-07-01 00:00:00',\n is_test: true,\n btdata: {\n billingDayOfMonth: 22,\n nextBillingDate: {\n date: nextPaymentFirstOfMonth.toISOString(),\n timezone_type: 3,\n timezone: 'UTC',\n },\n lastBillingDate: {\n date: lastPaymentWasOnTheFirstOfThisMonth.toISOString(),\n timezone_type: 3,\n timezone: 'UTC',\n },\n status: 'Active',\n paymentMethodType: 'Venmo',\n last4: null,\n cardType: null,\n expirationMonth: null,\n expirationYear: null,\n },\n});\n\nconst nextBillingDateYYYYMMDD = `${nextPaymentFirstOfMonth.getFullYear()}-${String(\n nextPaymentFirstOfMonth.getMonth() + 1\n).padStart(2, '0')}-${String(nextPaymentFirstOfMonth.getDate()).padStart(\n 2,\n '0'\n)}`;\n\ndescribe('<ia-mgc-edit-date>', () => {\n it('input validates before allowing form submission', async () => {\n const el = await fixture<MGCEditPlanDate>(\n html`<ia-mgc-edit-date .plan=${plan}></ia-mgc-edit-date>`\n );\n\n const amountLabel = el.shadowRoot?.querySelector('.current-date');\n expect(amountLabel).to.exist;\n expect(amountLabel?.textContent).to.contain(plan.nextBillingDateLocale);\n\n const cta = el.shadowRoot?.querySelector(\n 'ia-mgc-button#open-edit-date-form'\n );\n expect(cta).to.exist;\n\n // does not show form\n expect(el.form).to.not.exist;\n\n // does show form on Edit... click\n cta!.shadowRoot!.querySelector('button')!.click();\n await el.updateComplete;\n\n expect(el.form).to.exist;\n\n expect(el.hasAttribute('currentlyediting')).to.be.true;\n\n // form now displays\n expect(el.form.getAttribute('id')).to.equal('edit-date');\n\n const lastDateLabel = el.form.querySelector(\n '#form-info-last-donation-date'\n );\n const nextDateLabel = el.form.querySelector(\n '#form-info-next-donation-date'\n );\n\n expect(lastDateLabel).to.contain.text(plan.lastBillingDateLocale);\n expect(nextDateLabel).to.contain.text(plan.nextBillingDateLocale);\n\n const requestDateUpdateButton = el.form.querySelector(\n 'ia-mgc-button#edit-date'\n ) as MGCButton;\n expect(requestDateUpdateButton).to.exist;\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n\n expect(el.form.getAttribute('id')).to.equal('edit-date');\n\n // input has min and max range set\n // min is tomorrow, max is 12 months from now\n const dateInput = el.form.querySelector('input');\n expect(dateInput).to.exist;\n expect(dateInput!.getAttribute('type')).to.equal('date');\n expect(dateInput!.getAttribute('min')).to.equal(\n `${tomorrow.getFullYear()}-${String(tomorrow.getMonth() + 1).padStart(\n 2,\n '0'\n )}-${String(tomorrow.getDate()).padStart(2, '0')}`\n );\n expect(dateInput!.getAttribute('max')).to.equal(\n `${twelveMonthsFromNow.getFullYear()}-${String(\n twelveMonthsFromNow.getMonth() + 1\n ).padStart(2, '0')}-${String(twelveMonthsFromNow.getDate()).padStart(\n 2,\n '0'\n )}`\n );\n expect(dateInput!.value).to.equal(nextBillingDateYYYYMMDD);\n\n // checks if input value is invalid\n // date before today\n dateInput!.value = '2008-11-11';\n dateInput!.dispatchEvent(new Event('change'));\n await el.updateComplete;\n\n expect(el.errorMessage).to.contain('Date must be at least tomorrow.');\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n\n // date within 12 months\n const twoYearsFromNowStr = `${twoYearsFromNow.getFullYear()}-${String(\n twoYearsFromNow.getMonth() + 1\n ).padStart(2, '0')}-${String(twoYearsFromNow.getDate()).padStart(2, '0')}`;\n dateInput!.value = twoYearsFromNowStr;\n dateInput!.dispatchEvent(new Event('change'));\n await el.updateComplete;\n\n expect(el.errorMessage).to.contain(\n 'New donation date must be within the next 12 months.'\n );\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n\n // sets warning message when chosen date is in the same month as last payment\n const lastDayOfCurrentMonth = new Date();\n lastDayOfCurrentMonth.setHours(0, 0, 0, 0);\n lastDayOfCurrentMonth.setMonth(lastDayOfCurrentMonth.getMonth() + 1);\n lastDayOfCurrentMonth.setDate(0);\n\n const lastDayOfCurrentMonthStr = `${lastDayOfCurrentMonth.getFullYear()}-${String(\n lastDayOfCurrentMonth.getMonth() + 1\n ).padStart(2, '0')}-${lastDayOfCurrentMonth.getDate()}`;\n dateInput!.value = lastDayOfCurrentMonthStr;\n dateInput!.dispatchEvent(new Event('change'));\n await el.updateComplete;\n\n expect(el.warningMessage).to.contain(\n 'You have already made a donation this month.'\n );\n expect(el.errorMessage).to.contain(\n 'The date you selected will result in an additional donation for this month.'\n );\n expect(el.allowEditing).to.be.true;\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n expect(el.newDate).to.contain(\n `${lastDayOfCurrentMonth.getFullYear()}-${String(\n lastDayOfCurrentMonth.getMonth() + 1\n ).padStart(2, '0')}-${String(lastDayOfCurrentMonth.getDate()).padStart(\n 2,\n '0'\n )}`\n );\n\n // can submit when date is valid\n const nextMonthStr = `${nextMonth.getFullYear()}-${String(\n nextMonth.getMonth() + 1\n ).padStart(2, '0')}-${String(nextMonth.getDate()).padStart(2, '0')}`;\n dateInput!.value = nextMonthStr;\n dateInput!.dispatchEvent(new Event('change'));\n\n await el.updateComplete;\n\n expect(el.errorMessage).to.contain('');\n expect(el.newDate).to.contain(nextMonthStr);\n expect(el.allowEditing).to.be.true;\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.false;\n console.log(' ~~~ last test, button: ', requestDateUpdateButton);\n\n // clicking Update fires a Custom Event\n el.addEventListener('updateDate', (event: Event) => {\n console.log('updateDate event received ####', event);\n const { newDate } = (event as CustomEvent).detail;\n expect(newDate).to.contain(nextMonthStr);\n });\n\n requestDateUpdateButton.shadowRoot?.querySelector('button')?.click();\n await el.updateComplete;\n });\n});\n"]}
1
+ {"version":3,"file":"date.test.js","sourceRoot":"","sources":["../../../test/form-sections/date.test.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,8BAA8B,CAAC;AAEtC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E,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,uBAAuB,CAAC,CAAC;QAEjE,uCAAuC;QACvC,EAAE,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,KAAY,EAAE,EAAE;YACjD,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACrD,MAAM,EAAE,OAAO,EAAE,GAAI,KAAqB,CAAC,MAAM,CAAC;YAClD,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,MAAA,MAAA,uBAAuB,CAAC,UAAU,0CAAE,aAAa,CAAC,QAAQ,CAAC,0CAAE,KAAK,EAAE,CAAC;QACrE,MAAM,EAAE,CAAC,cAAc,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport { html, fixture, expect } from '@open-wc/testing';\n\nimport '../../src/form-sections/date';\nimport type { MGCEditPlanDate } from '../../src/form-sections/date';\nimport { MonthlyPlan } from '../../src/models/plan';\nimport type { MGCButton } from '../../src/presentational/mgc-button';\n\nconst lastPaymentWasOnTheFirstOfThisMonth = new Date();\nlastPaymentWasOnTheFirstOfThisMonth.setHours(0, 0, 0, 0);\nlastPaymentWasOnTheFirstOfThisMonth.setDate(1);\nconsole.log(\n 'lastPaymentWasOnTheFirstOfThisMonth',\n lastPaymentWasOnTheFirstOfThisMonth.toISOString()\n);\n\nconst nextMonth = new Date();\nnextMonth.setMonth(nextMonth.getMonth() + 1);\n\nconst nextPaymentFirstOfMonth = new Date(nextMonth);\nnextPaymentFirstOfMonth.setHours(0, 0, 0, 0);\nnextPaymentFirstOfMonth.setDate(1);\nconsole.log('nextPaymentFirstOfMonth', nextPaymentFirstOfMonth.toISOString());\n\nconst twelveMonthsFromNow = new Date();\ntwelveMonthsFromNow.setMonth(twelveMonthsFromNow.getMonth() + 12);\n\nconst twoYearsFromNow = new Date();\ntwoYearsFromNow.setFullYear(twoYearsFromNow.getFullYear() + 2);\ntwoYearsFromNow.setHours(0, 0, 0, 0);\n\nconst tomorrow = new Date();\ntomorrow.setDate(tomorrow.getDate() + 1);\n\nconst today = new Date();\ntoday.setHours(0, 0, 0, 0);\n\nconst yesterday = new Date();\nyesterday.setDate(yesterday.getDate() - 1);\nyesterday.setHours(0, 0, 0, 0);\n\nconst plan = new MonthlyPlan({\n token: 'a.va.lid.T0ken',\n amount: 5,\n currency: 'USD',\n start_date: '2024-07-01 00:00:00',\n is_test: true,\n btdata: {\n billingDayOfMonth: 22,\n nextBillingDate: {\n date: nextPaymentFirstOfMonth.toISOString(),\n timezone_type: 3,\n timezone: 'UTC',\n },\n lastBillingDate: {\n date: lastPaymentWasOnTheFirstOfThisMonth.toISOString(),\n timezone_type: 3,\n timezone: 'UTC',\n },\n status: 'Active',\n paymentMethodType: 'Venmo',\n last4: null,\n cardType: null,\n expirationMonth: null,\n expirationYear: null,\n },\n});\n\nconst nextBillingDateYYYYMMDD = `${nextPaymentFirstOfMonth.getFullYear()}-${String(\n nextPaymentFirstOfMonth.getMonth() + 1\n).padStart(2, '0')}-${String(nextPaymentFirstOfMonth.getDate()).padStart(\n 2,\n '0'\n)}`;\n\ndescribe('<ia-mgc-edit-date>', () => {\n it('input validates before allowing form submission', async () => {\n const el = await fixture<MGCEditPlanDate>(\n html`<ia-mgc-edit-date .plan=${plan}></ia-mgc-edit-date>`\n );\n\n const holder = el.shadowRoot?.querySelector('ia-mgc-form-section-info');\n expect(holder).to.equal(3);\n expect(holder?.textContent).to.contain(plan.nextBillingDateLocale);\n\n const cta = holder?.shadowRoot?.querySelector('ia-mgc-button');\n expect(cta).to.exist;\n\n // does not show form\n expect(el.form).to.not.exist;\n\n // does show form on Edit... click\n cta!.shadowRoot!.querySelector('button')!.click();\n await el.updateComplete;\n\n expect(el.form).to.exist;\n\n expect(el.hasAttribute('currentlyediting')).to.be.true;\n\n // form now displays\n expect(el.form.getAttribute('id')).to.equal('edit-date');\n\n const lastDateLabel = el.form.querySelector(\n '#form-info-last-donation-date'\n );\n const nextDateLabel = el.form.querySelector(\n '#form-info-next-donation-date'\n );\n\n expect(lastDateLabel).to.contain.text(plan.lastBillingDateLocale);\n expect(nextDateLabel).to.contain.text(plan.nextBillingDateLocale);\n\n const requestDateUpdateButton = el.form.querySelector(\n 'ia-mgc-button#edit-date'\n ) as MGCButton;\n expect(requestDateUpdateButton).to.exist;\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n\n expect(el.form.getAttribute('id')).to.equal('edit-date');\n\n // input has min and max range set\n // min is tomorrow, max is 12 months from now\n const dateInput = el.form.querySelector('input');\n expect(dateInput).to.exist;\n expect(dateInput!.getAttribute('type')).to.equal('date');\n expect(dateInput!.getAttribute('min')).to.equal(\n `${tomorrow.getFullYear()}-${String(tomorrow.getMonth() + 1).padStart(\n 2,\n '0'\n )}-${String(tomorrow.getDate()).padStart(2, '0')}`\n );\n expect(dateInput!.getAttribute('max')).to.equal(\n `${twelveMonthsFromNow.getFullYear()}-${String(\n twelveMonthsFromNow.getMonth() + 1\n ).padStart(2, '0')}-${String(twelveMonthsFromNow.getDate()).padStart(\n 2,\n '0'\n )}`\n );\n expect(dateInput!.value).to.equal(nextBillingDateYYYYMMDD);\n\n // checks if input value is invalid\n // date before today\n dateInput!.value = '2008-11-11';\n dateInput!.dispatchEvent(new Event('change'));\n await el.updateComplete;\n\n expect(el.errorMessage).to.contain('Date must be at least tomorrow.');\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n\n // date within 12 months\n const twoYearsFromNowStr = `${twoYearsFromNow.getFullYear()}-${String(\n twoYearsFromNow.getMonth() + 1\n ).padStart(2, '0')}-${String(twoYearsFromNow.getDate()).padStart(2, '0')}`;\n dateInput!.value = twoYearsFromNowStr;\n dateInput!.dispatchEvent(new Event('change'));\n await el.updateComplete;\n\n expect(el.errorMessage).to.contain(\n 'New donation date must be within the next 12 months.'\n );\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n\n // sets warning message when chosen date is in the same month as last payment\n const lastDayOfCurrentMonth = new Date();\n lastDayOfCurrentMonth.setHours(0, 0, 0, 0);\n lastDayOfCurrentMonth.setMonth(lastDayOfCurrentMonth.getMonth() + 1);\n lastDayOfCurrentMonth.setDate(0);\n\n const lastDayOfCurrentMonthStr = `${lastDayOfCurrentMonth.getFullYear()}-${String(\n lastDayOfCurrentMonth.getMonth() + 1\n ).padStart(2, '0')}-${lastDayOfCurrentMonth.getDate()}`;\n dateInput!.value = lastDayOfCurrentMonthStr;\n dateInput!.dispatchEvent(new Event('change'));\n await el.updateComplete;\n\n expect(el.warningMessage).to.contain(\n 'You have already made a donation this month.'\n );\n expect(el.errorMessage).to.contain(\n 'The date you selected will result in an additional donation for this month.'\n );\n expect(el.allowEditing).to.be.true;\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.true;\n expect(el.newDate).to.contain(\n `${lastDayOfCurrentMonth.getFullYear()}-${String(\n lastDayOfCurrentMonth.getMonth() + 1\n ).padStart(2, '0')}-${String(lastDayOfCurrentMonth.getDate()).padStart(\n 2,\n '0'\n )}`\n );\n\n // can submit when date is valid\n const nextMonthStr = `${nextMonth.getFullYear()}-${String(\n nextMonth.getMonth() + 1\n ).padStart(2, '0')}-${String(nextMonth.getDate()).padStart(2, '0')}`;\n dateInput!.value = nextMonthStr;\n dateInput!.dispatchEvent(new Event('change'));\n\n await el.updateComplete;\n\n expect(el.errorMessage).to.contain('');\n expect(el.newDate).to.contain(nextMonthStr);\n expect(el.allowEditing).to.be.true;\n expect(requestDateUpdateButton!.hasAttribute('isdisabled')).to.be.false;\n console.log(' ~~~ last test, button: ', requestDateUpdateButton);\n\n // clicking Update fires a Custom Event\n el.addEventListener('updateDate', (event: Event) => {\n console.log('updateDate event received ####', event);\n const { newDate } = (event as CustomEvent).detail;\n expect(newDate).to.contain(nextMonthStr);\n });\n\n requestDateUpdateButton.shadowRoot?.querySelector('button')?.click();\n await el.updateComplete;\n });\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/donation-monthly-portal",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "The Internet Archive Monthly Portal",
5
5
  "license": "AGPL-3.0-only",
6
6
  "main": "dist/index.js",
@@ -14,6 +14,7 @@ import {
14
14
  } from '@internetarchive/donation-form-data-models';
15
15
 
16
16
  import type { MonthlyPlan } from '../models/plan';
17
+ import '../presentational/donation-section-info';
17
18
  import '../presentational/mgc-button';
18
19
  import type { MGCButton } from '../presentational/mgc-button';
19
20
  import '../presentational/mgc-update-status';
@@ -60,22 +61,13 @@ export class MGCEditPlanAmount extends LitElement {
60
61
  <section>
61
62
  <donation-form-section badgemode="hidebadge" headline="Amount">
62
63
  ${!this.currentlyEditing
63
- ? html` <p class="current-amount">
64
- USD $${this.plan?.amount}
65
- <ia-mgc-update-status .status=${this.updateStatus}
66
- >${this.updateMessage}</ia-mgc-update-status
67
- >
68
- </p>
69
- <ia-mgc-button
70
- id="edit-amount"
71
- class="ia-button link"
72
- .clickHandler=${() => {
73
- this.currentlyEditing = true;
74
- this.clearStatusMessaging();
75
- }}
76
- >
77
- Edit...
78
- </ia-mgc-button>`
64
+ ? html`<ia-mgc-form-section-info
65
+ @editingRequested=${() => {
66
+ this.currentlyEditing = true;
67
+ this.clearStatusMessaging();
68
+ }}
69
+ ><span>USD $${this.plan?.amount}</span>
70
+ </ia-mgc-form-section-info>`
79
71
  : nothing}
80
72
  ${this.currentlyEditing ? this.editAmountForm : nothing}
81
73
  </donation-form-section>
@@ -75,22 +75,13 @@ export class MGCEditPlanDate extends LitElement {
75
75
  headline="Change next donation date"
76
76
  >
77
77
  ${!this.currentlyEditing
78
- ? html` <p class="current-date">
79
- ${this.plan?.nextBillingDateLocale}
80
- <ia-mgc-update-status .status=${this.updateStatus}
81
- >${this.updateMessage}</ia-mgc-update-status
82
- >
83
- </p>
84
- <ia-mgc-button
85
- id="open-edit-date-form"
86
- class="ia-button link"
87
- .clickHandler=${() => {
88
- this.currentlyEditing = true;
89
- this.clearStatusMessaging();
90
- }}
91
- >
92
- Edit...
93
- </ia-mgc-button>`
78
+ ? html`<ia-mgc-form-section-info
79
+ @editingRequested=${() => {
80
+ this.currentlyEditing = true;
81
+ this.clearStatusMessaging();
82
+ }}
83
+ ><span>${this.plan?.nextBillingDateLocale}</span>
84
+ </ia-mgc-form-section-info>`
94
85
  : nothing}
95
86
  ${this.currentlyEditing ? this.editDateForm : nothing}
96
87
  </donation-form-section>
@@ -168,7 +168,7 @@ export class MonthlyGivingCircle extends LitElement {
168
168
  title = 'Recent donations';
169
169
  titleStyle = 'default';
170
170
  cta = html`<ia-mgc-button
171
- class="link slim"
171
+ class="primary"
172
172
  id="close-receipts"
173
173
  .clickHandler=${async () => {
174
174
  this.viewToDisplay = this.plans.length ? 'plans' : 'welcome';
package/src/plans.ts CHANGED
@@ -118,7 +118,7 @@ export class IauxMgcPlans extends LitElement {
118
118
  static styles = css`
119
119
  :host {
120
120
  max-height: 500px;
121
- overflow-y: scroll;
121
+ overflow-y: auto;
122
122
  display: block;
123
123
  }
124
124
 
@@ -0,0 +1,25 @@
1
+ import { LitElement, html } from 'lit';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import './mgc-button';
4
+ import type { MGCButton } from './mgc-button';
5
+
6
+ @customElement('ia-mgc-form-section-info')
7
+ export class MGCFormSectionInfo extends LitElement {
8
+ protected render() {
9
+ return html`
10
+ <div class="mgc-donation-section-info">
11
+ <p><slot></slot></p>
12
+ <ia-mgc-button
13
+ class="ia-button link"
14
+ .clickHandler=${(_event: Event, iaButton: MGCButton) => {
15
+ // eslint-disable-next-line no-param-reassign
16
+ iaButton.isDisabled = true;
17
+ this.dispatchEvent(new Event('editingRequested'));
18
+ }}
19
+ >
20
+ Edit...
21
+ </ia-mgc-button>
22
+ </div>
23
+ `;
24
+ }
25
+ }
@@ -31,6 +31,7 @@ export class MGCTitle extends LitElement {
31
31
  :host {
32
32
  padding-bottom: 5px;
33
33
  display: block;
34
+ --link-button-padding: 0.5rem;
34
35
  }
35
36
 
36
37
  :host([titlestyle='default']) h2 {
@@ -51,7 +52,7 @@ export class MGCTitle extends LitElement {
51
52
  align-content: center;
52
53
  margin: 0;
53
54
  justify-content: space-between;
54
- align-items: flex-end;
55
+ align-items: center;
55
56
  line-height: normal;
56
57
  }
57
58
 
@@ -77,6 +78,10 @@ export class MGCTitle extends LitElement {
77
78
  align-items: flex-end;
78
79
  }
79
80
 
81
+ ia-mgc-button {
82
+ --link-button-padding: 0.5rem;
83
+ }
84
+
80
85
  @media screen and (max-width: 450px) {
81
86
  h2,
82
87
  slot[name='action'] {