Skip to content

Commit

Permalink
feat: Add error prefix to title when error is triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
Top-Cat committed Nov 27, 2024
1 parent 0907cec commit b15e2a3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public FamilyHubsUiOptions GetAlternative(string serviceName)
return alternativeFamilyHubsUi;
}

public bool IsError { get; set; }

/// <summary>
/// Returns an absolute URL from the Urls config section/dictionary, with an optional relativeUrl applied to the base..
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface IFamilyHubsUiOptions
FooterOptions Footer { get; set; }

FamilyHubsUiOptions GetAlternative(string serviceName);
bool IsError { get; set; }

Uri Url<TUrlKeyEnum>(TUrlKeyEnum baseUrl, string? relativeUrl = null)
where TUrlKeyEnum : struct, Enum;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using FamilyHubs.SharedKernel.Razor.ErrorNext;

namespace FamilyHubs.SharedKernel.Razor.Header;

public interface IHasErrorStatePageModel
{
public IErrorState Errors { get; }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using FamilyHubs.SharedKernel.Razor.AlternativeServices;
using FamilyHubs.SharedKernel.Razor.FamilyHubsUi;
using FamilyHubs.SharedKernel.Razor.FamilyHubsUi.Extensions;
using FamilyHubs.SharedKernel.Razor.Header;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.ViewFeatures;

Expand All @@ -20,6 +21,12 @@ public static void InitialiseFamilyHubs(FamilyHubsLayoutModel familyHubsLayoutMo
familyHubsLayoutModel.FamilyHubsUiOptions = Options.Create(altFamilyHubsUiOptions);
}
}

if (pageModel is IHasErrorStatePageModel hasErrorStatePageModel)
{
familyHubsLayoutModel.FamilyHubsUiOptions.Value.IsError = hasErrorStatePageModel.Errors.HasErrors;
}

viewData.SetFamilyHubsLayoutModel(familyHubsLayoutModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<partial name="_MicrosoftClarity.cshtml" model="Model"/>

<meta charset="utf-8" />
<title>@ViewData["Title"] - @Model.ServiceName - GOV.UK</title>
<title>@if (Model.IsError) { <text>Error: </text> }@ViewData["Title"] - @Model.ServiceName - GOV.UK</title>
<meta name="description" content="@Model.ServiceName">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#0b0c0c">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using FamilyHubs.Referral.Web.Pages.Shared;
using FamilyHubs.SharedKernel.Identity;
using FamilyHubs.SharedKernel.Razor.ErrorNext;
using FamilyHubs.SharedKernel.Razor.Header;
using Microsoft.AspNetCore.Mvc;

namespace FamilyHubs.Referral.Web.Pages.My_Account;

public class ChangeNameModel : HeaderPageModel
public class ChangeNameModel : HeaderPageModel, IHasErrorStatePageModel
{
private readonly IIdamsClient _idamsClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using FamilyHubs.Referral.Core.Models;
using FamilyHubs.Referral.Web.Errors;
using FamilyHubs.SharedKernel.Razor.ErrorNext;
using FamilyHubs.SharedKernel.Razor.Header;
using Microsoft.AspNetCore.Mvc;

namespace FamilyHubs.Referral.Web.Pages.Shared;

public class ProfessionalReferralCacheModel : ProfessionalReferralModel
public class ProfessionalReferralCacheModel : ProfessionalReferralModel, IHasErrorStatePageModel
{
// we could stop passing this to get/set
public ConnectionRequestModel? ConnectionRequestModel { get; set; }
Expand Down

0 comments on commit b15e2a3

Please sign in to comment.