import { Component }     from '@angular/core';

import { Router }        from '@angular/router';
import { Location }      from '@angular/common';

import { SharedService } from '../../../services/svc.shared';

@Component({
    moduleId: module.id+ '',
    selector: 'modal',
    templateUrl: './tpl.modal.pug',
    styleUrls: ['./sty.modal.scss']
})

export class ModalComponent {

    display: boolean;

    constructor (
        private _sharedService: SharedService,
        private _location: Location,
        private _router: Router
    ) {

       this.display = false;
       this._sharedService.modalCalled$.subscribe(
            () => {
                console.log('click recieved');
                this.onCartAdd(true);
            }
        )
    }

    onCartAdd(state: boolean) {
        this.display = state;
    }

   close() {
       this.display = false;
    }

    gotoCart() {
        this.display = false;

        this._router.navigateByUrl('/basket')
    }
}