@page "/Error"
@using System.Diagnostics

@inject IStringLocalizer<Error> Localizer

<PageTitle>@(Localizer["Title"] + TitlePostfix)</PageTitle>

<h1 class="text-3xl lg:text-5xl font-light text-primary">@Localizer["Title"]</h1>

<p class="my-3">@Localizer["Message"]</p>

@if (ShowRequestId) {
    <p>
        <strong>Request ID:</strong>&ensp;<code>@RequestId</code>
    </p>
}

@code {
    [CascadingParameter(Name = "TitlePostfix")]
    private string TitlePostfix { get; set; } = default!;
    [CascadingParameter]
    private HttpContext? HttpContext { get; set; }

    private string? RequestId { get; set; }
    private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

    protected override void OnInitialized() => RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}
