From af21e50d9f9b77f4f8a5ccf4fe234ca63c539bb8 Mon Sep 17 00:00:00 2001 From: Chris Chen Date: Thu, 28 May 2026 17:41:19 -0700 Subject: [PATCH] feat(giving): add reopen-and-edit flow + recent sessions list to offering page --- .../offering-session-page.component.html | 28 ++++++++-- .../offering-session-page.component.scss | 2 + .../offering-session-page.component.ts | 54 +++++++++++++++++-- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/APP/src/app/features/giving/pages/offering-session-page/offering-session-page.component.html b/APP/src/app/features/giving/pages/offering-session-page/offering-session-page.component.html index 151bae4..deff8b5 100644 --- a/APP/src/app/features/giving/pages/offering-session-page/offering-session-page.component.html +++ b/APP/src/app/features/giving/pages/offering-session-page/offering-session-page.component.html @@ -2,11 +2,16 @@ -
+
+ Editing submitted session — make changes and click "Update Session". + +
+ +
An offering session for this date already exists. Pick another date, or reopen the existing session to edit.
@@ -61,7 +66,24 @@
Difference: {{ difference | currency }}
+ [disabled]="buffer.length === 0 || (editingSessionId == null && dateConflict) || submitting" + (click)="submit()">{{ editingSessionId != null ? 'Update Session' : 'Submit' }} + + +
+

Recent Sessions

+ + + + + + + + + + + +
s + (l.amount || 0), 0); } @@ -69,6 +75,42 @@ export class OfferingSessionPageComponent implements OnInit { this.api.checkDate(this.toIso(this.sessionDate)).subscribe(r => this.dateConflict = r.exists); } + loadSessions(): void { + this.api.getPaged(1, 20).subscribe(r => this.sessions = r.items); + } + + reopenAndEdit(s: OfferingSessionListItemDto): void { + if (s.status !== 'Submitted') return; + this.api.reopen(s.id).subscribe({ + next: () => this.api.getById(s.id).subscribe(dto => this.loadIntoBuffer(dto)), + error: (err: { error?: { message?: string } }) => alert(err?.error?.message ?? 'Reopen failed.'), + }); + } + + private loadIntoBuffer(dto: OfferingSessionDto): void { + this.editingSessionId = dto.id; + this.sessionDate = new Date(dto.sessionDate + 'T00:00:00'); + this.dateConflict = false; + this.cashTotal = dto.cashTotal; + this.checkTotal = dto.checkTotal; + this.notes = dto.notes; + this.buffer = dto.givings.map(g => ({ + memberId: g.memberId, givingCategoryId: g.givingCategoryId, amount: g.amount, + paymentMethod: g.paymentMethod, checkNumber: g.checkNumber, + zelleReferenceCode: g.zelleReferenceCode, payPalTransactionId: g.payPalTransactionId, + isAnonymous: g.isAnonymous, notes: g.notes, + memberName: g.memberName, categoryName: g.categoryName, + })); + this.resetEntry(); + } + + cancelEdit(): void { + this.editingSessionId = null; + this.buffer = []; this.cashTotal = 0; this.checkTotal = 0; this.notes = null; + this.sessionDate = new Date(); + this.checkDate(); + } + onMemberFilter(term: string): void { if (!term) { this.memberResults = []; return; } this.memberApi.getPaged({ search: term, pageSize: 10 }).subscribe(r => @@ -123,7 +165,7 @@ export class OfferingSessionPageComponent implements OnInit { } submit(): void { - if (this.buffer.length === 0 || this.dateConflict) return; + if (this.buffer.length === 0 || (this.editingSessionId == null && this.dateConflict)) return; this.submitting = true; const req: CreateOfferingSessionRequest = { sessionDate: this.toIso(this.sessionDate), @@ -142,12 +184,18 @@ export class OfferingSessionPageComponent implements OnInit { notes: l.notes, })), }; - this.api.create(req).subscribe({ + const obs: Observable = this.editingSessionId != null + ? this.api.replace(this.editingSessionId, req) + : this.api.create(req); + obs.subscribe({ next: () => { this.submitting = false; - alert('Offering session submitted.'); + alert(this.editingSessionId != null ? 'Offering session updated.' : 'Offering session submitted.'); + this.editingSessionId = null; this.buffer = []; this.cashTotal = 0; this.checkTotal = 0; this.notes = null; + this.sessionDate = new Date(); this.checkDate(); + this.loadSessions(); }, error: (err: { error?: { message?: string } }) => { this.submitting = false;