|
| 1 | +/* eslint-disable no-console */ |
1 | 2 | import { LitElement, html, css, PropertyValues, nothing } from 'lit'; |
2 | 3 | import { customElement, property } from 'lit/decorators.js'; |
3 | 4 | import { classMap } from 'lit/directives/class-map.js'; |
@@ -27,17 +28,16 @@ export class IauxMgcReceipts extends LitElement { |
27 | 28 | @property({ type: Object }) |
28 | 29 | donationEmailStatusMap: donationEmailStatusMapType | null = null; |
29 | 30 |
|
30 | | - shouldUpdate(changed: PropertyValues) { |
31 | | - if (changed.has('donationEmailStatusMap')) { |
32 | | - return true; |
33 | | - } |
34 | | - return true; |
35 | | - } |
36 | | - |
37 | 31 | updated(changed: PropertyValues) { |
38 | 32 | if (changed.has('receipts')) { |
39 | 33 | this.updateReceiptSentMap(); |
40 | 34 | } |
| 35 | + if (changed.has('donationEmailStatusMap')) { |
| 36 | + console.log( |
| 37 | + 'donationEmailStatusMap UPDATED ---- ', |
| 38 | + this.donationEmailStatusMap |
| 39 | + ); |
| 40 | + } |
41 | 41 | } |
42 | 42 |
|
43 | 43 | updateReceiptSentMap() { |
@@ -94,22 +94,30 @@ export class IauxMgcReceipts extends LitElement { |
94 | 94 | ); |
95 | 95 | } |
96 | 96 |
|
97 | | - public emailSent(receiptEmailed: donationEmailStatus) { |
| 97 | + async emailSent(receiptEmailed: donationEmailStatus) { |
| 98 | + const currStatusMap = this.donationEmailStatusMap; |
| 99 | + this.donationEmailStatusMap = null; |
| 100 | + await this.updateComplete; |
98 | 101 | const statusMap = { |
99 | | - ...this.donationEmailStatusMap, |
| 102 | + ...currStatusMap, |
100 | 103 | } as donationEmailStatusMapType; |
101 | 104 | const { id } = receiptEmailed; |
102 | 105 | statusMap[id] = receiptEmailed; |
103 | | - this.donationEmailStatusMap = statusMap; |
104 | | - // this.requestUpdate(); |
| 106 | + |
| 107 | + this.donationEmailStatusMap = { ...statusMap }; |
| 108 | + console.log( |
| 109 | + 'RECEIPTS -- emailSent', |
| 110 | + this.donationEmailStatusMap, |
| 111 | + receiptEmailed |
| 112 | + ); |
105 | 113 | } |
106 | 114 |
|
107 | 115 | emailStatusMessageToDisplay(donationSentStatus: donationEmailStatus): string { |
108 | 116 | switch (donationSentStatus.emailStatus) { |
109 | 117 | case 'success': |
110 | | - return 'Email sent'; |
| 118 | + return '✓ Email receipt sent'; |
111 | 119 | case 'fail': |
112 | | - return 'Email did not send'; |
| 120 | + return '✖ Email receipt failed'; |
113 | 121 | default: |
114 | 122 | return ''; |
115 | 123 | } |
@@ -185,10 +193,6 @@ export class IauxMgcReceipts extends LitElement { |
185 | 193 | } as donationEmailStatusMapType; |
186 | 194 | statusMap[donation.id].emailStatus = 'pending'; |
187 | 195 | this.donationEmailStatusMap = statusMap; |
188 | | - console.log( |
189 | | - 'this.donationEmailStatusMap', |
190 | | - this.donationEmailStatusMap |
191 | | - ); |
192 | 196 | } |
193 | 197 | }} |
194 | 198 | ?disabled=${emailUnavailable} |
@@ -237,11 +241,26 @@ export class IauxMgcReceipts extends LitElement { |
237 | 241 | } |
238 | 242 | iaux-button-style { |
239 | 243 | display: inline-block; |
240 | | - padding-right: 5px; |
| 244 | + } |
| 245 | +
|
| 246 | + .request-receipt { |
| 247 | + display: flex; |
| 248 | + flex-wrap: nowrap; |
| 249 | + align-content: center; |
| 250 | + justify-content: flex-start; |
| 251 | + align-items: center; |
| 252 | + gap: 20px; |
| 253 | + } |
| 254 | +
|
| 255 | + .sent-status.success, |
| 256 | + .sent-status.fail { |
| 257 | + padding: 5px; |
| 258 | + background: rgb(238, 253, 238); |
| 259 | + width: 135px; |
| 260 | + min-height: 20px; |
241 | 261 | } |
242 | 262 | .sent-status.success { |
243 | 263 | color: rgb(33, 149, 24); |
244 | | - cursor: pointer; |
245 | 264 | border-left: 5px solid rgb(33, 149, 24); |
246 | 265 | } |
247 | 266 | .sent-status.fail { |
|
0 commit comments