diff options
author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-04-05 13:17:29 -0400 |
---|---|---|
committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-04-05 13:17:29 -0400 |
commit | d7c974a98de42f41f3ca16f961d2dee96a3c4313 (patch) | |
tree | 32751f8ef2b16b7c957a3fbb82d8664b24239583 /ufund-ui/src/app/components/funding-basket/funding-basket.component.ts | |
parent | 5a5d31896d79a736bce33b7d1aa7b3168ba308a9 (diff) | |
download | JellySolutions-d7c974a98de42f41f3ca16f961d2dee96a3c4313.tar.gz JellySolutions-d7c974a98de42f41f3ca16f961d2dee96a3c4313.tar.bz2 JellySolutions-d7c974a98de42f41f3ca16f961d2dee96a3c4313.zip |
Added running total to checkout
Diffstat (limited to 'ufund-ui/src/app/components/funding-basket/funding-basket.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/funding-basket/funding-basket.component.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts index a39b4f3..a0ba609 100644 --- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts +++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.ts @@ -2,9 +2,10 @@ import {Component, Input, OnInit, ViewChild} from '@angular/core'; import {UsersService} from '../../services/users.service'; import {Router} from '@angular/router'; import {CupboardService} from '../../services/cupboard.service'; -import {firstValueFrom} from 'rxjs'; +import {BehaviorSubject, firstValueFrom} from 'rxjs'; import {AuthService} from '../../services/auth.service'; import {ToastsService, ToastType} from '../../services/toasts.service'; +import {GoalType} from '../../models/Need'; @Component({ selector: 'app-funding-basket', @@ -22,6 +23,7 @@ export class FundingBasketComponent implements OnInit { private toastService: ToastsService ) {} + public runningTotal = new BehaviorSubject(0) @ViewChild("contribution") contribution?: Input; // this is for login rerouting @@ -63,9 +65,17 @@ export class FundingBasketComponent implements OnInit { } resetColor(ev: any) { + let total = 0 + this.runningTotal.next(total); for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) { - + this.cupboardService.getNeed(+contribution.id).subscribe(need => { + if (contribution.value != '' && need.type != GoalType.PHYSICAL) { + total += contribution.valueAsNumber + } + this.runningTotal.next(total); + }) } + (ev.target as HTMLInputElement).setAttribute("style", "border-color: unset") } } |