namespace MidrandBookshop.Components;

public partial class RedirectToLogin
{
    protected override void OnInitialized()
    {
        var relativePath = Navigation.ToBaseRelativePath(Navigation.Uri);
        var sanitizedRedirectPath = relativePath.StartsWith('/') ? relativePath : $"/{relativePath}";

        Navigation.NavigateTo($"/login?redirectUri={Uri.EscapeDataString(sanitizedRedirectPath)}", forceLoad: true);
    }
}
