This commit is contained in:
andrei-mihnea-cerbu
2024-04-08 13:37:58 +03:00
parent 333ad8be09
commit 370bbdedcd
164 changed files with 3915 additions and 161 deletions
@@ -0,0 +1,12 @@
@if (!string.IsNullOrEmpty(ErrorMessage))
{
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Error:</strong> @ErrorMessage
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
}
@code {
[Parameter]
public string ErrorMessage { get; set; }
}
@@ -0,0 +1,15 @@
@page "/"
@using HealthcareManagerUI.Components.Layout
@layout AuthLayout
<head>
<title>Choose Role</title>
</head>
<link rel="stylesheet" href="bootstrap/dist/css/bootstrap.min.css"/>
<div class="text-center mt-5 centered-menu">
<h1 class="landingTitle">Welcome to Healthcare Manager</h1>
<p class="landingSubtitle">Please select your role:</p>
<div class="button-container">
<NavLink class="btn btn-primary m-2" href="/login/doctor">I'm a Doctor</NavLink>
<NavLink class="btn btn-secondary m-2" href="/login/patient">I'm a Patient</NavLink>
</div>
</div>
@@ -0,0 +1,9 @@
@page "/dashboard"
<head>
<title>Dashboard</title>
</head>
<h3>Dashboard</h3>
<h1>login success</h1>
@code {
}
@@ -0,0 +1,77 @@
@page "/login/{role}"
@using HealthcareManagerUI.Models
@using HealthcareManagerUI.Services.Authentication
@using HealthcareManagerUI.Components.Layout
@layout AuthLayout
@inject IAuthenticationService AuthenticationService
@inject NavigationManager NavigationManager
<head>
<title>Login</title>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<link rel="stylesheet" href="/LoginPage.css" />
<link rel="stylesheet" href="/bootstrap/dist/css/bootstrap.min.css" />
<EditForm Model="userLoginModel" OnValidSubmit="@HandleLogin" FormName="LoginForm" class="login-form container mt-5">
<DataAnnotationsValidator/>
<ValidationSummary/>
<div class="card shadow-lg">
<div class="card-body">
<h3 class="card-title text-center mb-3">Login</h3>
<div class="form-group mb-3">
<InputText id="email" class="form-control" placeholder="Email" @bind-Value="userLoginModel!.Email"></InputText>
</div>
<div class="form-group mb-3">
<InputText id="password" class="form-control" type="password" placeholder="Password" @bind-Value="userLoginModel!.Password"></InputText>
</div>
<button type="submit" class="btn btn-primary w-100 mb-3">Log In</button>
<div class="button-container">
<NavLink class="btn btn-secondary m-2" href="@($"/register/{Role}")">Register</NavLink>
<NavLink class="btn btn-secondary m-2" href="@($"/reset-password/{Role}")">Reset Password</NavLink>
</div>
</div>
</div>
</EditForm>
<AlertMessage ErrorMessage="@errorMessage" />
@code {
[SupplyParameterFromForm]
public UserLoginModel? userLoginModel { get; set; }
protected override void OnInitialized()
{
userLoginModel ??= new();
}
[Parameter] public string Role { get; set; }
private string errorMessage { get; set; }
private void ClearErrorMessage()
{
errorMessage = string.Empty;
}
private async Task HandleLogin()
{
var response = Role switch
{
"doctor" => await AuthenticationService.LoginDoctor(userLoginModel),
"patient" => await AuthenticationService.LoginPatient(userLoginModel),
_ => null
};
if (response.StatusCode >= 200 && response.StatusCode <= 399)
{
NavigationManager.NavigateTo("/dashboard");
}
else
{
errorMessage = response.Message;
}
}
}
@@ -0,0 +1,84 @@
@page "/register/{role}"
@using HealthcareManagerUI.Models
@using HealthcareManagerUI.Services.Authentication
@using HealthcareManagerUI.Components.Layout
@layout AuthLayout
@inject IAuthenticationService AuthenticationService
@inject NavigationManager NavigationManager
<head>
<title>Register</title>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<link rel="stylesheet" href="/LoginPage.css" />
<link rel="stylesheet" href="/bootstrap/dist/css/bootstrap.min.css" />
<EditForm Model="userRegisterModel" OnValidSubmit="@HandleRegister" FormName="RegisterForm" class="login-form container mt-5">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="card shadow-lg">
<div class="card-body">
<h3 class="card-title text-center mb-3">Register</h3>
<div class="form-group mb-3">
<InputText id="name" class="form-control" placeholder="Name" @bind-Value="userRegisterModel!.Name"></InputText>
</div>
@if (Role.Equals("doctor", StringComparison.OrdinalIgnoreCase))
{
<div class="form-group mb-3">
<InputText id="description" class="form-control" placeholder="Description" @bind-Value="userRegisterModel!.Description"></InputText>
</div>
}
<div class="form-group mb-3">
<InputText id="email" class="form-control" placeholder="Email" @bind-Value="userRegisterModel!.Email"></InputText>
</div>
<div class="form-group mb-3">
<InputText id="password" class="form-control" type="password" placeholder="Password" @bind-Value="userRegisterModel!.Password"></InputText>
</div>
<div class="button-container">
<button type="submit" class="btn btn-primary w-100 mb-3">Register</button>
</div>
</div>
</div>
</EditForm>
<AlertMessage ErrorMessage="@errorMessage" />
@code {
[SupplyParameterFromForm]
public UserRegisterModel? userRegisterModel { get; set; }
protected override void OnInitialized()
{
userRegisterModel ??= new();
}
[Parameter] public string Role { get; set; }
private string errorMessage { get; set; }
private void ClearErrorMessage()
{
errorMessage = string.Empty;
}
private async Task HandleRegister()
{
var response = Role switch
{
"doctor" => await AuthenticationService.RegisterDoctor(userRegisterModel),
"patient" => await AuthenticationService.RegisterPatient(userRegisterModel),
_ => null
};
if (response.StatusCode >=200 && response.StatusCode <= 399)
{
NavigationManager.NavigateTo($"/login/{Role}");
}
else
{
errorMessage = response.Message;
}
}
}
@@ -0,0 +1,75 @@
@page "/reset-password/{role}"
@using HealthcareManagerUI.Models
@using HealthcareManagerUI.Services.Authentication
@using HealthcareManagerUI.Components.Layout
@layout AuthLayout
@inject IAuthenticationService AuthenticationService
@inject NavigationManager NavigationManager
<head>
<title>Reset your password</title>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<link rel="stylesheet" href="/LoginPage.css" />
<link rel="stylesheet" href="/bootstrap/dist/css/bootstrap.min.css" />
<EditForm Model="userResetPasswordModel" OnValidSubmit="@HandleResetPassword" FormName="ResetPasswordForm" class="login-form container mt-5">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="card shadow-lg">
<div class="card-body">
<h3 class="card-title text-center mb-3">Register</h3>
<div class="form-group mb-3">
<InputText id="email" class="form-control" placeholder="Email" @bind-Value="userResetPasswordModel!.Email"></InputText>
</div>
<div class="form-group mb-3">
<InputText id="password" class="form-control" type="password" placeholder="New Password" @bind-Value="userResetPasswordModel!.Password"></InputText>
</div>
<div class="button-container">
<button type="submit" class="btn btn-primary w-100 mb-3">Reset Password</button>
</div>
</div>
</div>
</EditForm>
<AlertMessage ErrorMessage="@errorMessage" />
@code {
[SupplyParameterFromForm]
public UserRegisterModel? userResetPasswordModel { get; set; }
protected override void OnInitialized()
{
userResetPasswordModel ??= new();
}
[Parameter] public string Role { get; set; }
private string errorMessage { get; set; }
private void ClearErrorMessage()
{
errorMessage = string.Empty;
}
private async Task HandleResetPassword()
{
var response = Role switch
{
"doctor" => await AuthenticationService.ResetDoctorPassword(userResetPasswordModel),
"patient" => await AuthenticationService.ResetPatientPassword(userResetPasswordModel),
_ => null
};
if (response.StatusCode >= 200 && response.StatusCode <= 399)
{
NavigationManager.NavigateTo($"/login/{Role}");
}
else
{
errorMessage = response.Message;
}
}
}