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

Location:
Farmatiko/ClientApp/src/app
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Farmatiko/ClientApp/src/app/admin/admin.component.html

    rad60966 r1db5673  
    7676            <input matInput [(ngModel)]="this.head.Passwd">
    7777          </mat-form-field><br>
    78             <button onclick="createHead()" mat-raised-button color="primary">Create</button>
     78            <button (click)="createHead()" mat-raised-button color="primary">Create</button>
    7979          </div>
    8080        </mat-tab>
  • 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  }
  • Farmatiko/ClientApp/src/app/login/login.component.ts

    rad60966 r1db5673  
    5454      .subscribe(
    5555        (data) => {
    56           if(data.role == 'Admin') {
     56          if(data.role === 'Admin') {
    5757            this.router.navigate(['/admin']);
    5858          }
  • Farmatiko/ClientApp/src/app/shared/data.service.ts

    rad60966 r1db5673  
    66
    77import { IHealthFacilities, IHealthcareWorkers, IMedicine, IPandemic, IPharmacy, IPharmacyHead, IPharmacyHeadRequest } from './interfaces';
     8import { environment } from '../../environments/environment';
    89
    910@Injectable()
    1011export class DataService {
    11     baseFacilitiesUrl: string = '/api/facilities';
    12     baseWorkersUrl: string = '/api/workers';
    13     baseMedicineUrl: string = '/api/medicines';
    14     basePandemicUrl: string = '/api/pandemic';
    15     basePharmacyUrl: string = '/api/pharmacy';
    16     basePharmacyHead: string = '/api/pharmacyhead';
     12    baseFacilitiesUrl: string = `${environment.baseApiUrl}api/facilities`;
     13    baseWorkersUrl: string = `${environment.baseApiUrl}api/workers`;
     14    baseMedicineUrl: string = `${environment.baseApiUrl}api/medicines`;
     15    basePandemicUrl: string = `${environment.baseApiUrl}api/pandemic`;
     16    basePharmacyUrl: string = `${environment.baseApiUrl}api/pharmacy`;
     17    basePharmacyHead: string = `${environment.baseApiUrl}api/pharmacyhead`;
    1718
    1819    constructor(private http: HttpClient) {
     
    179180    //PharmacyHead PUT
    180181    updatePharmacyHead(head: IPharmacyHead) : Observable<IPharmacyHead> {
    181         return this.http.put<IPharmacyHead>(this.basePharmacyHead + '/' + head.id, head)
     182        return this.http.put<IPharmacyHead>(this.basePharmacyHead, head)
    182183                   .pipe(
    183184                        map((data) => {
  • Farmatiko/ClientApp/src/app/shared/interfaces.ts

    rad60966 r1db5673  
    5757    originalUserName?: string;
    5858    Role?: string;
    59 
    60 
     59}
    6160export interface IPharmacyHeadRequest {
    6261    id?: string;
  • Farmatiko/ClientApp/src/app/shared/services/auth.service.ts

    rad60966 r1db5673  
    99
    1010interface LoginResult {
    11   username: string;
     11  userName: string;
    1212  role: string;
    1313  originalUserName?: string;
     
    3636        this.http.get<LoginResult>(`${this.apiUrl}/user`).subscribe((x) => {
    3737          this._user.next({
    38             Email: x.username,
     38            Email: x.userName,
    3939            Passwd: x.head.Passwd,
    4040            Role: x.role,
     
    6464        map((x) => {
    6565          this._user.next({
    66             Email: x.username,
     66            Email: x.userName,
    6767            Passwd: x.head.Passwd,
    6868            Role: x.role,
     
    105105        map((x) => {
    106106          this._user.next({
    107             Email: x.username,
     107            Email: x.userName,
    108108            Passwd: x.head.Passwd,
    109109            Role: x.role,
Note: See TracChangeset for help on using the changeset viewer.