diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-04-07 21:00:53 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-04-07 21:00:53 -0400 |
commit | 426b21de0a3f7ee8706b83af4acddb731798be2c (patch) | |
tree | b51bda63a4bbbef158353600a878e8192f7f7952 /ufund-ui/src/app/components/funding-basket/funding-basket.component.ts | |
parent | 71e01e85a33b0109847867878b2af733b4751e46 (diff) | |
parent | 7617db08a43d873a65abd47b02e23ad8cb4cb5cd (diff) | |
download | JellySolutions-426b21de0a3f7ee8706b83af4acddb731798be2c.tar.gz JellySolutions-426b21de0a3f7ee8706b83af4acddb731798be2c.tar.bz2 JellySolutions-426b21de0a3f7ee8706b83af4acddb731798be2c.zip |
Merge branch 'main' into call-to-action
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 | 15 |
1 files changed, 13 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 78ce958..920a7ef 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 @@ -24,7 +24,8 @@ export class FundingBasketComponent implements OnInit { private toastService: ToastsService ) {} - public runningTotal = new BehaviorSubject(0) + protected runningTotal = new BehaviorSubject(0) + protected physicalTotal: string[] = [] @ViewChild("contribution") contribution?: Input; ngOnInit(): void { @@ -36,6 +37,9 @@ export class FundingBasketComponent implements OnInit { let order: { needID: number, quantity: number }[] = [] let isNotValid = false + this.runningTotal.next(0); + this.physicalTotal = [] + for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) { if (contribution.value == '' || contribution.valueAsNumber <= 0) { isNotValid = true @@ -60,21 +64,28 @@ export class FundingBasketComponent implements OnInit { this.toastService.sendToast(ToastType.INFO, "Checkout successful"); } - resetColor(ev: any) { + onInput(ev: any) { let total = 0 this.runningTotal.next(total); + this.physicalTotal = [] 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 + } else if (contribution.value != '' && need.type == GoalType.PHYSICAL) { + this.physicalTotal.push(need.name + ": " + contribution.value) } this.runningTotal.next(total); + }) } + this.physicalTotal.sort((a, b) => a < b ? -1 : 1); + (ev.target as HTMLInputElement).setAttribute("style", "border-color: unset") } protected readonly of = of; protected readonly userType = userType; + protected readonly Infinity = Infinity; } |