using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Seenginx.Shared
{
	public class NavMenuBase : ComponentBase
	{
		protected Dictionary<string, string> ActiveNav { get; set; }
		public bool CollapsePanel { get; set; } = false;

		protected async override Task OnInitializedAsync()
		{
			ActiveNav = new Dictionary<string, string>
			{
				{ "nginx", null },
				{ "nginxlogs", null },
				{ "systemd", null },
				{ "systemdlogs", null },
				{ "dmesg", null }
			};
			await base.OnInitializedAsync();
		}

		protected void SelectMenuItem(string menuItem)
		{
			foreach (var key in ActiveNav.Keys.ToArray())
				ActiveNav[key] = null;

			ActiveNav[menuItem] = "is-active";
		}
	}
}
