import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute, NavigationStart, NavigationEnd} from '@angular/router';
import {AppConfig} from '../config/app.config';

@Component({
    templateUrl: 'home.component.html',
    styleUrls: ['home.component.scss']
})

export class HomeComponent implements OnInit {
    auth: boolean;

    constructor(private route: ActivatedRoute,
                private router: Router) {
        this.auth = false;

        this.router.events.filter(event => event instanceof NavigationEnd).subscribe((event: NavigationEnd) => {
            this.auth = event.url !== '/';
        });
    }

    openCategories() {
        this.router.navigate([AppConfig.routes.categories]);
    }

    openLists() {
        this.router.navigate([AppConfig.routes.lists]);
    }

    openSearch() {
        this.router.navigate([AppConfig.routes.search]);
    }

    logOut() {
        this.auth = false;
        this.router.navigate([AppConfig.routes.login]);
    }

    ngOnInit() {

    }
}
