@page "/register" @using BlazorFrontend.Services @using BlazorFrontend.Providers @using LibraryManagement.Shared.Models @using Microsoft.AspNetCore.Components.Authorization @inject HttpClient Http @inject NavigationManager Navigation Register

Join our Library

Start your reading journey today.

@if (!string.IsNullOrEmpty(_errorMessage)) {
@_errorMessage
}
Already have an account? Sign in
@code { [SupplyParameterFromForm] private RegisterRequest _registerRequest { get; set; } = new(); private string? _errorMessage; private bool _isLoading; private async Task HandleRegister() { try { _isLoading = true; _errorMessage = null; var res = await Http.PostAsJsonAsync("api/auth/register", _registerRequest); if (res.IsSuccessStatusCode) { Navigation.NavigateTo("/login"); } else { _errorMessage = "Registration failed. This email might already be in use."; } } catch (Exception ex) { _errorMessage = "An error occurred: " + ex.Message; } finally { _isLoading = false; } } }