import { Component , OnInit } from '@angular/core' ; import { Router } from "@angular/router" ; import { RetailShopsService , RetailShop } from "../../services/shop.service" ; import { UsersService } from "../../services/users.service" ; @ Component ( { selector : 'app-user' , templateUrl : './user.component.html' , styleUrls : [ './user.component.scss' ] } ) export class UserComponent implements OnInit { shops : RetailShop [ ] ; shop : RetailShop ; constructor ( private _router , private _userService , private _shopService ) { } ngOnInit ( ) { this . shop = this . _shopService . shop ; this . shops = this . _shopService . shops ; this . _shopService . shops$ . subscribe ( ( data ) => { this . shops = data ; } ) ; this . _shopService . shop$ . subscribe ( ( data ) => { this . shop = data ; } ) ; } logout ( ) { this . _userService . logout ( ) . then ( ( ) => { this . _router . navigate ( [ '/login' ] ) ; } ) ; } openProfile ( ) { } setShop ( shop ? ) { console . log ( shop ) ; if ( ! shop ) { shop = < RetailShop > { } ; } this . _shopService . shop = shop ; this . shop = shop ; } }