using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; namespace Biskilog_Accounting.Client.Elements { public partial class Headbar { private const string c_show = "show"; private const string c_hide = "hidden"; private string m_dropDownClass = c_hide; protected override void OnInitialized() { m_searchService.ClearTextBox += ClearTextBox; m_searchService.CloseMenus += HideProfileDropdown; base.OnInitialized(); } private void HideProfileDropdown(string a_sender) { if (a_sender != "Profile") { m_dropDownClass = c_hide; StateHasChanged(); } } private void ToggleDropdown() { if (m_dropDownClass == c_hide) { m_dropDownClass = c_show; } else { m_dropDownClass = c_hide; } } private void ClearTextBox() { ClearInputField("mainSearch"); } private async Task ClearInputField(string elementId) { await JSRuntime.InvokeVoidAsync("eval", $"document.getElementById('{elementId}').value = ''"); } private void SearchInput(string a_key) { m_searchService.PerformSearch(a_key); } private async Task LogOut() { await m_tokenService.ClearToken(); m_navigationManager.NavigateTo("/login"); } } }