11/* eslint-disable no-debugger */
22
3- import { LitElement , html , TemplateResult , nothing , PropertyValues } from 'lit' ;
3+ import { LitElement , html , TemplateResult , PropertyValues } from 'lit' ;
44import { customElement , property } from 'lit/decorators.js' ;
55
66import './welcome-message' ;
@@ -106,11 +106,41 @@ export class MonthlyGivingCircle extends LitElement {
106106 get sectionTitle ( ) : TemplateResult {
107107 let title = '' ;
108108 let titleStyle = '' ;
109+ let cta = html `` ;
110+
111+ const receiptsCTA = html `
112+ < ia-button
113+ class ="link slim "
114+ .clickHandler =${ async ( ) => {
115+ this . viewToDisplay = 'receipts' ;
116+ await this . updateComplete ;
117+ this . dispatchEvent ( new CustomEvent ( 'ShowReceipts' ) ) ;
118+ } }
119+ >
120+ View recent donation history
121+ </ ia-button >
122+ ` ;
123+
124+ const displayReceiptsLink =
125+ this . receipts . length &&
126+ ( this . viewToDisplay === 'plans' || this . viewToDisplay === 'welcome' ) ;
109127
110128 switch ( this . viewToDisplay ) {
111129 case 'receipts' :
112130 title = 'Recent donations' ;
113131 titleStyle = 'default' ;
132+ cta = html `< ia-button
133+ class ="link slim "
134+ id ="close-receipts "
135+ .clickHandler =${ async ( ) => {
136+ this . viewToDisplay = this . plans . length ? 'plans' : 'welcome' ;
137+ this . dispatchEvent ( new CustomEvent ( 'ShowWelcome' ) ) ;
138+ this . updates = [ ] ;
139+ await this . updateComplete ;
140+ } }
141+ >
142+ Back to account settings
143+ </ ia-button > ` ;
114144 break ;
115145
116146 case 'editPlan' :
@@ -121,30 +151,16 @@ export class MonthlyGivingCircle extends LitElement {
121151 default :
122152 title = 'Monthly Giving Circle' ;
123153 titleStyle = 'heart' ;
154+ if ( displayReceiptsLink ) {
155+ cta = receiptsCTA ;
156+ }
124157 break ;
125158 }
126159
127- const displayReceiptsLink =
128- this . receipts . length &&
129- ( this . viewToDisplay === 'plans' || this . viewToDisplay === 'welcome' ) ;
130- const receiptsCTA = html `
131- < ia-button
132- class ="link slim "
133- .clickHandler =${ async ( ) => {
134- this . viewToDisplay = 'receipts' ;
135- await this . updateComplete ;
136- this . dispatchEvent ( new CustomEvent ( 'ShowReceipts' ) ) ;
137- } }
138- >
139- View recent donation history
140- </ ia-button >
141- ` ;
142160 return html `
143161 < ia-mgc-title titleStyle =${ titleStyle } >
144162 < span slot ="title "> ${ title } </ span >
145- < span slot ="action "
146- > ${ displayReceiptsLink ? receiptsCTA : nothing } </ span
147- >
163+ < span slot ="action "> ${ cta } </ span >
148164 </ ia-mgc-title >
149165 ` ;
150166 }
@@ -173,6 +189,7 @@ export class MonthlyGivingCircle extends LitElement {
173189 @editThisPlan =${ ( event : CustomEvent ) => {
174190 this . editingThisPlan = event . detail . plan ;
175191 this . viewToDisplay = 'editPlan' ;
192+ this . dispatchEvent ( new Event ( 'ShowEditForm' ) ) ;
176193 } }
177194 .plans =${ this . plans }
178195 > </ ia-mgc-plans >
0 commit comments