Tax is added directly to product for sale
Auth guard and auth service simplified and fixed so that user is updated upon login Home component changed to use square buttons Fixed showing the totals in the bill ng linted the project
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Subject} from 'rxjs';
|
||||
import {AuthService} from '../auth/auth.service';
|
||||
import { Component, OnInit} from '@angular/core';
|
||||
import { AuthService} from '../auth/auth.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map, share } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
@ -8,18 +9,15 @@ import {AuthService} from '../auth/auth.service';
|
||||
styleUrls: ['./home.component.css']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
public nameObject = new Subject<string>();
|
||||
public user: Observable<string>;
|
||||
|
||||
constructor(private auth: AuthService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.auth.userObservable.subscribe((user) => {
|
||||
if (user.isAuthenticated) {
|
||||
this.nameObject.next(user.name);
|
||||
} else {
|
||||
this.nameObject.next(null);
|
||||
}
|
||||
});
|
||||
this.user = this.auth.userObservable.pipe(
|
||||
map (x => x.isAuthenticated ? x.name : null),
|
||||
share()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user