diff options
| author | Gunther6070 <haydenhartman10@yahoo.com> | 2025-04-03 15:35:12 -0400 | 
|---|---|---|
| committer | Gunther6070 <haydenhartman10@yahoo.com> | 2025-04-03 15:35:12 -0400 | 
| commit | 75f5ad5fb154811d7acd236687bb7f30bb7c10aa (patch) | |
| tree | d2f8d353ebf2ffb80c72de943a6ab810fd773261 /ufund-ui | |
| parent | 26b4a37cb91dfe5551f3e227512cd5ceff897d54 (diff) | |
| download | JellySolutions-75f5ad5fb154811d7acd236687bb7f30bb7c10aa.tar.gz JellySolutions-75f5ad5fb154811d7acd236687bb7f30bb7c10aa.tar.bz2 JellySolutions-75f5ad5fb154811d7acd236687bb7f30bb7c10aa.zip  | |
Fixed incognito race condition and checkout bugs
Diffstat (limited to '')
3 files changed, 7 insertions, 20 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 015d5b5..5d94124 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,7 +2,7 @@ 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 {catchError, firstValueFrom, Observable} from 'rxjs'; +import {firstValueFrom} from 'rxjs';  import {AuthService} from '../../services/auth.service';  import {ToastsService, ToastType} from '../../services/toasts.service'; @@ -32,11 +32,10 @@ export class FundingBasketComponent implements OnInit {          }          this.usersService.refreshBasket(); -        // this.usersService.removeNeed(); <- call this to remove      }      async checkout() { -        let order: { id: number, quantity: number }[] = [] +        let order: { needID: number, quantity: number }[] = []          for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) {              if (contribution.value == '' || contribution.valueAsNumber <= 0) { @@ -44,31 +43,21 @@ export class FundingBasketComponent implements OnInit {                  this.toastService.sendToast(ToastType.ERROR, "Invalid input in funding basket!")                  return;              } -            order.push({id: +contribution.id, quantity: contribution.valueAsNumber}); +            order.push({needID: +contribution.id, quantity: contribution.valueAsNumber});          }          try { -            this.cupboardService.checkoutNeed(order) +            await firstValueFrom(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() +        order.forEach(contribution => this.usersService.removeNeed(contribution.needID)) +        this.toastService.sendToast(ToastType.INFO, "Checkout successful");      }      resetColor(ev: any) { -        // console.log(ev);          (ev.target as HTMLInputElement).setAttribute("style", "border-color: unset")      }  } diff --git a/ufund-ui/src/app/components/toast/toast.component.ts b/ufund-ui/src/app/components/toast/toast.component.ts index 47fd7ff..6bbae34 100644 --- a/ufund-ui/src/app/components/toast/toast.component.ts +++ b/ufund-ui/src/app/components/toast/toast.component.ts @@ -21,7 +21,6 @@ export class ToastComponent implements OnInit{      }      hide() { -        console.log(this.toastDiv, typeof this.toastDiv)          this.toastDiv.nativeElement.classList.add('hide')      } diff --git a/ufund-ui/src/app/services/cupboard.service.ts b/ufund-ui/src/app/services/cupboard.service.ts index 786973e..1060476 100644 --- a/ufund-ui/src/app/services/cupboard.service.ts +++ b/ufund-ui/src/app/services/cupboard.service.ts @@ -47,8 +47,7 @@ export class CupboardService {          return this.http.delete<boolean>(`${this.url}/${id}`, this.httpOptions())      } -    checkoutNeed(data: {id: number, quantity: number}[]) { -        console.log("GOT HERE") +    checkoutNeed(data: {needID: number, quantity: number}[]) {          return this.http.put(`${this.url}/checkout`, data, this.httpOptions())      }  }  | 
