aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui')
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.css8
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.html1
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.ts18
3 files changed, 24 insertions, 3 deletions
diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css
index c46ef57..a1485a0 100644
--- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.css
+++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.css
@@ -80,3 +80,11 @@
padding: 5px;
gap: 5px;
}
+
+#footer {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ gap: 20px;
+ margin-bottom: 10px;
+}
diff --git a/ufund-ui/src/app/components/funding-basket/funding-basket.component.html b/ufund-ui/src/app/components/funding-basket/funding-basket.component.html
index c4b12c9..7158194 100644
--- a/ufund-ui/src/app/components/funding-basket/funding-basket.component.html
+++ b/ufund-ui/src/app/components/funding-basket/funding-basket.component.html
@@ -12,6 +12,7 @@
<br>
<div id="footer">
<button class="button2" title="checkout" (click)="checkout()">Checkout</button>
+ <span id="running-total">Your current running total is: ${{runningTotal | async}}</span>
</div>
</ng-template>
<div *ngIf="!usersService.getBasket().getValue().length">
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 371015a..78ce958 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,10 +2,11 @@ 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, of} from 'rxjs';
+import {BehaviorSubject, firstValueFrom, of} from 'rxjs';
import {AuthService} from '../../services/auth.service';
import {ToastsService, ToastType} from '../../services/toasts.service';
import {userType} from '../../models/User';
+import {GoalType} from '../../models/Need';
@Component({
selector: 'app-funding-basket',
@@ -23,6 +24,7 @@ export class FundingBasketComponent implements OnInit {
private toastService: ToastsService
) {}
+ public runningTotal = new BehaviorSubject(0)
@ViewChild("contribution") contribution?: Input;
ngOnInit(): void {
@@ -59,8 +61,18 @@ export class FundingBasketComponent implements OnInit {
}
resetColor(ev: any) {
- // for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) {}
- (ev.target as HTMLInputElement).setAttribute("style", "")
+ 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")
}
protected readonly of = of;