diff --git a/Shifty.App/Pages/Login.razor b/Shifty.App/Pages/Login.razor index 44b823d..9aa4920 100644 --- a/Shifty.App/Pages/Login.razor +++ b/Shifty.App/Pages/Login.razor @@ -6,31 +6,20 @@ @attribute [AllowAnonymous] - + Please login - + - @if (_loggingIn) - { - - } - else - { - if (!_successfulLogin) - { - Invalid credentials - } - - - } + @code { - bool _loggingIn = false; - bool _successfulLogin = true; - LoginForm _loginForm = new(); - + [Inject] private IDialogService DialogService { get; set; } + + readonly LoginForm _loginForm = new(); + public class LoginForm { - [Required] - [EmailAddress] - public string Email { get; set; } + [Required] [EmailAddress] public string Email { get; set; } } async Task LoginUser() { - _successfulLogin = true; - _loggingIn = true; - _successfulLogin = await _authenticationService.LoginUser(_loginForm.Email); - _loggingIn = false; - if (_successfulLogin) + _ = await _authenticationService.LoginUser(_loginForm.Email) switch { - Navigation.NavigateTo("/"); - } + true => await DialogService.ShowMessageBox( + "Email sent", + "A magic link has been sent to your email address. Please check your inbox to login." + ), + _ => await DialogService.ShowMessageBox( + "Error", + "An error occured. Please wait a few minutes and try again." + ) + }; } + } \ No newline at end of file