From d6f84719fa46c07a60e8f739eefb774a7ac24a48 Mon Sep 17 00:00:00 2001 From: Greg Finzer Date: Tue, 27 Aug 2024 21:38:08 -0400 Subject: [PATCH] Fix console errors --- BedBrigade.Client/Components/Pages/Index.razor.cs | 15 ++++++++++++--- BedBrigade.Client/Components/Pages/Sorry.razor | 5 ++--- .../Components/SearchLocation.razor.cs | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/BedBrigade.Client/Components/Pages/Index.razor.cs b/BedBrigade.Client/Components/Pages/Index.razor.cs index 8508af88..8d6aac58 100644 --- a/BedBrigade.Client/Components/Pages/Index.razor.cs +++ b/BedBrigade.Client/Components/Pages/Index.razor.cs @@ -40,17 +40,22 @@ protected override async Task OnParametersSetAsync() { string location = string.IsNullOrEmpty(mylocation) ? defaultLocation : mylocation; string pageName = string.IsNullOrEmpty(mypageName) ? defaultPageName : mypageName; - _locationState.Location = location; + if (previousLocation.ToLower() != location.ToLower() || previousPageName.ToLower() != pageName.ToLower()) { previousLocation = location; previousPageName = pageName; - await LoadLocationPage(location, pageName); + bool loaded= await LoadLocationPage(location, pageName); + + if (loaded) + { + _locationState.Location = location; + } } } - private async Task LoadLocationPage(string location, string pageName) + private async Task LoadLocationPage(string location, string pageName) { Log.Logger.Debug("Index.LoadLocationPage"); @@ -73,11 +78,13 @@ private async Task LoadLocationPage(string location, string pageName) else { _navigationManager.NavigateTo("/Sorry", true); + return false; } } else { _navigationManager.NavigateTo("/Sorry", true); + return false; } } catch (Exception ex) @@ -85,6 +92,8 @@ private async Task LoadLocationPage(string location, string pageName) Log.Logger.Error(ex, $"LoadLocationPage: {ex.Message}"); throw; } + + return true; } } } diff --git a/BedBrigade.Client/Components/Pages/Sorry.razor b/BedBrigade.Client/Components/Pages/Sorry.razor index 9d71931f..c95815dc 100644 --- a/BedBrigade.Client/Components/Pages/Sorry.razor +++ b/BedBrigade.Client/Components/Pages/Sorry.razor @@ -1,8 +1,7 @@ @page "/sorry" Sorry -

Sorry - the page associated with this link was not found.

+

Sorry - the page associated with this link was not found.

@code { - //TODO: Add notification codes. - // Add notification codes. + //TODO: Add notification code. } diff --git a/BedBrigade.Client/Components/SearchLocation.razor.cs b/BedBrigade.Client/Components/SearchLocation.razor.cs index 86c2d1c1..c5a5b479 100644 --- a/BedBrigade.Client/Components/SearchLocation.razor.cs +++ b/BedBrigade.Client/Components/SearchLocation.razor.cs @@ -120,7 +120,7 @@ private bool ValidatePostalCode() if (!Regex.IsMatch(PostalCode, @"\d{5}$")) { strAlertType = "alert alert-danger"; - PostalCodeResult = "Error! Zip code must be numeric and have a length of 5."; + PostalCodeResult = "Zip code must be numeric and have a length of 5."; return false; } @@ -154,7 +154,7 @@ private async Task HandleSearchClick() if (!Result.Success || Result.Data == null) { strAlertType = AlertDanger; - PostalCodeResult = "Error! " + Result.Message; + PostalCodeResult = Result.Message; Locations = new List(); // empty location list await SetZipBoxFocus(); return;