import { Component, OnInit } from '@angular/core'

// Services
import { MenuService }      from '@k-services/svc.menu'
import { HelperService }    from '@k-services/svc.helper'

// Types
import { SecondaryNav }		from '../../../../../types/secondary-nav'

@Component({
	selector: 'menu-inline-secondary',
	templateUrl: 'tpl.menu-inline-secondary.pug',
	styleUrls: ['./sty.menu-inline-secondary.scss']
})
export class MenuInlineSecondaryComponent implements OnInit {

	constructor(
		private _menuService: MenuService,
		private _helper: HelperService
	) { 
		// Subscribe to active state
		_menuService.secondaryState$.subscribe((result) => {
			this.secondaryState = result
		})

		// Subscribe to menu
		_menuService.secondaryMenu$.subscribe((result) => {
			this.parent = result.parent
			this.type = result.type
			this.menu = result.menu
		})
	}

	// Vars
	type: string;
	parent: string;
	menu;
	categoryLabel = this._helper.categories
	secondaryState: boolean


	// Lifecycle hooks
	ngOnInit() { 

	}


	// Functions

	/**
	 * Closes the secondary menu and resets primary
	 */
	closeSecondary() {
		this._menuService.closeSecondary()
		this._menuService.setActivePrimary('')
	}

}