diff --git a/src/BirthList.Web/Components/Account/Pages/Manage/Index.razor b/src/BirthList.Web/Components/Account/Pages/Manage/Index.razor index 3fb6298..6ac6eb9 100644 --- a/src/BirthList.Web/Components/Account/Pages/Manage/Index.razor +++ b/src/BirthList.Web/Components/Account/Pages/Manage/Index.razor @@ -23,6 +23,21 @@ +
+ + + +
+
+ + + +
+
+ + + +
@@ -51,6 +66,9 @@ phoneNumber = await UserManager.GetPhoneNumberAsync(user); Input.PhoneNumber ??= phoneNumber; + Input.FirstName ??= user.FirstName; + Input.LastName ??= user.LastName; + Input.Address ??= user.Address; } private async Task OnValidSubmitAsync() @@ -64,12 +82,34 @@ } } + user.FirstName = string.IsNullOrWhiteSpace(Input.FirstName) ? null : Input.FirstName.Trim(); + user.LastName = string.IsNullOrWhiteSpace(Input.LastName) ? null : Input.LastName.Trim(); + user.Address = string.IsNullOrWhiteSpace(Input.Address) ? null : Input.Address.Trim(); + + var updateResult = await UserManager.UpdateAsync(user); + if (!updateResult.Succeeded) + { + RedirectManager.RedirectToCurrentPageWithStatus("Error: Failed to update profile.", HttpContext); + } + await SignInManager.RefreshSignInAsync(user); RedirectManager.RedirectToCurrentPageWithStatus("Your profile has been updated", HttpContext); } private sealed class InputModel { + [StringLength(100)] + [Display(Name = "First name")] + public string? FirstName { get; set; } + + [StringLength(100)] + [Display(Name = "Last name")] + public string? LastName { get; set; } + + [StringLength(500)] + [Display(Name = "Address")] + public string? Address { get; set; } + [Phone] [Display(Name = "Phone number")] public string? PhoneNumber { get; set; } diff --git a/src/BirthList.Web/Components/Layout/TopBar.razor b/src/BirthList.Web/Components/Layout/TopBar.razor index 20a66d8..9e991b6 100644 --- a/src/BirthList.Web/Components/Layout/TopBar.razor +++ b/src/BirthList.Web/Components/Layout/TopBar.razor @@ -1,7 +1,19 @@ +@using BirthList.Web.Features.Registries +@using BirthList.Web.Services @implements IDisposable @inject NavigationManager NavigationManager @inject AuthenticationStateProvider AuthenticationStateProvider +@inject RegistryUserContext RegistryUserContext +@inject ProfileCompletionService ProfileCompletionService + +@if (ShowProfileCompletionPrompt) +{ +
+ Please complete your profile (first name, last name, and address). + Complete profile +
+}