diff options
Diffstat (limited to 'ufund-ui/src/app/components/funding-basket')
| -rw-r--r-- | ufund-ui/src/app/components/funding-basket/funding-basket.component.html | 60 | ||||
| -rw-r--r-- | ufund-ui/src/app/components/funding-basket/funding-basket.component.ts | 19 | 
2 files changed, 28 insertions, 51 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 bba66a3..3f840e1 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,44 +1,24 @@  <div id="box"> -    <h1>Funding Basket</h1> -    <ng-template [ngIf]="usersService.getBasket().getValue().length"> -        <div id="needList"> -            <div *ngFor="let need of usersService.getBasket().getValue()" class="needEntry"> -                <div [routerLink]="'/need/' + need.id" class="clickable"> -                    <div class="split"> -                        <div class="left"> -                            <span class="needName">{{need.name}}</span> -                            <span class="needType">{{need.type}}</span> -                        </div> - -                        <div class="right"> -                            <span *ngIf="need.urgent" class="urgent">URGENT</span> -                            <span *ngIf="need.location"><span class="icon">location_on</span>{{need.location}}</span> -                        </div> -                    </div> - -                    <br> - -                    <div class="prog"> -                        <span id="hover-status-label-{{need.id}}"> </span> -                        <span>{{need.current}}/{{need.maxGoal}} ({{((need.current / need.maxGoal) * 100).toFixed(0)}}%)</span> -                        <progress [value]="need.current" [max]="need.maxGoal"></progress> -                    </div> -                </div> - -                <div class="actionArea"> -                    <input type="number" placeholder="Quantity" min="1" [id]="need.id" class="contribution" (input)="resetColor($event)"> -                    <button class="removeNeed" title="delete need" (click)="this.usersService.removeNeed(need.id)"> -                        <span class="icon">delete</span> Remove from Basket -                    </button> -                </div> +    @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" (input)="resetColor($event)"> +                <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> +        <div *ngIf="!usersService.getBasket().getValue().length"> +            <span>There are no needs in your basket! </span><a routerLink="/cupboard">Browse the cupboard</a>          </div> -        <br> -        <div id="footer"> -            <button class="button2" title="checkout" (click)="checkout()">Checkout</button> -        </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 a39b4f3..371015a 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,9 +2,10 @@ 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} from 'rxjs'; +import {firstValueFrom, 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,18 +19,13 @@ 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; -    // this is for login rerouting      ngOnInit(): void { -        if (!this.authService.getCurrentUser()) { -            this.router.navigate(['/login'], {queryParams: {redir: this.router.url}}); -            return; -        }          this.usersService.refreshBasket();      } @@ -63,9 +59,10 @@ export class FundingBasketComponent implements OnInit {      }      resetColor(ev: any) { -        for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) { - -        } -        (ev.target as HTMLInputElement).setAttribute("style", "border-color: unset") +        // for (let contribution of document.querySelectorAll<HTMLInputElement>('.contribution')!) {} +        (ev.target as HTMLInputElement).setAttribute("style", "")      } + +    protected readonly of = of; +    protected readonly userType = userType;  }  | 
