aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components')
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.ts30
1 files changed, 18 insertions, 12 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 18bb9b8..015d5b5 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
@@ -47,22 +47,28 @@ export class FundingBasketComponent implements OnInit {
order.push({id: +contribution.id, quantity: contribution.valueAsNumber});
}
- for (let c of document.querySelectorAll('.contribution')!) {
- let contribution = c as HTMLInputElement;
- try {
- let need = await firstValueFrom(this.cupboardService.getNeed(+contribution.id));
- await firstValueFrom(this.cupboardService.checkoutNeed(need.id, +contribution.value));
- need.current += +contribution.value;
- this.usersService.removeNeed(+need.id);
- this.toastService.sendToast(ToastType.INFO, "Checkout successful");
- } catch (ex: any) {
- this.toastService.sendToast(ToastType.ERROR, ex.error);
- }
+ try {
+ this.cupboardService.checkoutNeed(order)
+ } catch (ex:any) {
+ this.toastService.sendToast(ToastType.ERROR, ex.error);
+ return
}
+
+ console.log(order)
+
+ for (let contribution of order) {
+ let need = await firstValueFrom(this.cupboardService.getNeed(contribution.id))
+ need.current += contribution.quantity;
+ this.usersService.removeNeed(need.id);
+ this.toastService.sendToast(ToastType.INFO, "Checkout successful");
+ }
+
+ // this.usersService.getBasket().subscribe(console.log)
+ // this.usersService.refreshBasket()
}
resetColor(ev: any) {
- console.log(ev);
+ // console.log(ev);
(ev.target as HTMLInputElement).setAttribute("style", "border-color: unset")
}
}