aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/funding-basket
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/funding-basket')
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.html35
-rw-r--r--ufund-ui/src/app/components/funding-basket/funding-basket.component.ts9
2 files changed, 23 insertions, 21 deletions
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 edc9609..fcd5437 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
@@ -1,19 +1,24 @@
<div id="box">
- <h1>Funding Basket</h1>
- <ng-template [ngIf]="(usersService.getBasket() | async)?.length">
- <ng-template let-need #NLActions>
- <input type="number" placeholder="Quantity" min="1" [id]="need?.id" class="contribution">
- <button class="removeNeed" (click)="this.usersService.removeNeed(need.id)">
- <span class="icon">delete</span>Remove from Basket
- </button>
+ @if ((authService.getCurrentUserSubject() | async)?.type === userType.HELPER) {
+ <h1>Funding Basket</h1>
+ <ng-template [ngIf]="(usersService.getBasket() | async)?.length">
+ <ng-template let-need #NLActions>
+ <input type="number" placeholder="Quantity" min="1" [id]="need?.id" class="contribution">
+ <button class="removeNeed" (click)="this.usersService.removeNeed(need.id)">
+ <span class="icon">delete</span>Remove from Basket
+ </button>
+ </ng-template>
+ <app-need-list [actionArea]="NLActions" [needs]="(usersService.getBasket() | async)!"/>
+ <br>
+ <div id="footer">
+ <button class="button2" title="checkout" (click)="checkout()">Checkout</button>
+ </div>
</ng-template>
- <app-need-list [actionArea]="NLActions" [needs]="(usersService.getBasket() | async)!"/>
- <br>
- <div id="footer">
- <button class="button2" title="checkout" (click)="checkout()">Checkout</button>
+ <div *ngIf="!usersService.getBasket().getValue().length">
+ <span>There are no needs in your basket! </span><a routerLink="/cupboard">Browse the cupboard</a>
</div>
- </ng-template>
- <div *ngIf="!usersService.getBasket().getValue().length">
- <span>There are no needs in your basket! </span><a routerLink="/cupboard">Browse the cupboard</a>
- </div>
+ } @else {
+ <h1>Unauthorized</h1>
+ <span>This page requires you to be logged in as a user! <a routerLink="/login">Log In</a></span>
+ }
</div>
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 0b3b9f3..767327e 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
@@ -5,6 +5,7 @@ import {CupboardService} from '../../services/cupboard.service';
import {catchError, firstValueFrom, Observable, of} from 'rxjs';
import {AuthService} from '../../services/auth.service';
import {ToastsService, ToastType} from '../../services/toasts.service';
+import {userType} from '../../models/User';
@Component({
selector: 'app-funding-basket',
@@ -18,19 +19,14 @@ export class FundingBasketComponent implements OnInit {
private router: Router,
protected cupboardService: CupboardService,
protected usersService: UsersService,
- private authService: AuthService,
+ protected authService: AuthService,
private toastService: ToastsService
) {}
@ViewChild("contribution") contribution?: Input;
@Input() isValid: boolean = true;
- // this is for login rerouting
ngOnInit(): void {
- if (!this.authService.getCurrentUser()) {
- this.router.navigate(['/login'], {queryParams: {redir: this.router.url}});
- return;
- }
this.usersService.refreshBasket();
// this.usersService.removeNeed(); <- call this to remove
@@ -92,4 +88,5 @@ export class FundingBasketComponent implements OnInit {
protected readonly of = of;
+ protected readonly userType = userType;
}