Ignore:
Timestamp:
11/14/20 12:27:30 (4 years ago)
Author:
DimitarSlezenkovski <dslezenkovski@…>
Branches:
master
Children:
68454c6
Parents:
ad60966
Message:

Fix bugs, add some more

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/dashboard/dashboard.component.ts

    rad60966 r1db5673  
    4343 
    4444  claimPharmacy(pharmacy: IPharmacy) {
    45     if(pharmacy && !this.head.Pharmacy.find(x => x === pharmacy)) {
    46       this.request = null;
    47       this.request.Pharmacy = pharmacy;
    48       this.request.PharmacyHead = this.head;
    49       this.dataService.claimPharmacy(this.request)
    50           .subscribe((req: IPharmacyHeadRequest) => {
    51             if(req) {
    52               this.openSnackBar("Claiming request sent!", "OK");
    53             }
    54             else {
    55               this.openSnackBar("Unable to send a request", "Try again");
    56             }
    57           },
    58           (err: any) => console.log(err),
    59           () => console.log('Claiming request sent!'));
     45    if(this.head.Pharmacy != null) {
     46      if(pharmacy && !this.head.Pharmacy.find(x => x === pharmacy)) {
     47        this.request = {};
     48        this.request.Pharmacy = pharmacy;
     49        this.request.PharmacyHead = this.head;
     50        this.dataService.claimPharmacy(this.request)
     51            .subscribe((req) => {
     52              if(req) {
     53                this.openSnackBar("Claiming request sent!", "OK");
     54              }
     55              else {
     56                this.openSnackBar("Unable to send a request", "Try again");
     57              }
     58            },
     59            (err: any) => console.log(err),
     60            () => console.log('Claiming request sent!'));
     61      }
     62    }
     63    else {
     64      if(pharmacy) {
     65        this.request = {};
     66        this.request.Pharmacy = pharmacy;
     67        this.request.PharmacyHead = this.head;
     68        this.dataService.claimPharmacy(this.request)
     69            .subscribe((req) => {
     70              if(req) {
     71                this.openSnackBar("Claiming request sent!", "OK");
     72              }
     73              else {
     74                this.openSnackBar("Unable to send a request", "Try again");
     75              }
     76            },
     77            (err: any) => console.log(err),
     78            () => console.log('Claiming request sent!'));
     79      }
    6080    }
    6181  }
Note: See TracChangeset for help on using the changeset viewer.