diff --git a/CulinaryCommandApp/Components/Layout/NavMenu.razor b/CulinaryCommandApp/Components/Layout/NavMenu.razor index 7cc76f7..cb3896c 100644 --- a/CulinaryCommandApp/Components/Layout/NavMenu.razor +++ b/CulinaryCommandApp/Components/Layout/NavMenu.razor @@ -52,11 +52,6 @@ Recipes - - - @@ -86,8 +84,7 @@
Location @(locIndex + 1)
-
@@ -182,43 +201,46 @@ @code { @@ -350,6 +392,26 @@ private string FirstName { get; set; } = string.Empty; private string LastName { get; set; } = string.Empty; + // Password requirement flags + private bool PasswordHasMinLength => Signup.Admin.Password?.Length >= 8; + private bool PasswordHasUpper => !string.IsNullOrEmpty(Signup.Admin.Password) && + Signup.Admin.Password.Any(char.IsUpper); + private bool PasswordHasLower => !string.IsNullOrEmpty(Signup.Admin.Password) && + Signup.Admin.Password.Any(char.IsLower); + private bool PasswordHasNumber => !string.IsNullOrEmpty(Signup.Admin.Password) && + Signup.Admin.Password.Any(char.IsDigit); + private bool PasswordHasSymbol => !string.IsNullOrEmpty(Signup.Admin.Password) && Signup.Admin.Password.Any(c => + CognitoSymbols.Contains(c)); + + // Cognito symbol set (same as in CognitoPasswordAttribute) + private const string CognitoSymbols = "^$*.[\\]{}()?\"!@#%&/\\,><':;|_~`=+-"; + + private void OnPasswordInput(ChangeEventArgs e) + { + // This triggers UI update as the password changes + StateHasChanged(); + } + protected override void OnInitialized() { Signup.Locations ??= new List(); @@ -373,7 +435,7 @@ { errorMessage = ""; successMessage = ""; - + if (string.IsNullOrWhiteSpace(FirstName) || string.IsNullOrWhiteSpace(LastName)) { errorMessage = "First and last name are required."; @@ -400,4 +462,4 @@ isSubmitting = false; } } -} +} \ No newline at end of file diff --git a/CulinaryCommandApp/Inventory/Pages/Ingredients/Create.razor b/CulinaryCommandApp/Inventory/Pages/Ingredients/Create.razor deleted file mode 100644 index d10de52..0000000 --- a/CulinaryCommandApp/Inventory/Pages/Ingredients/Create.razor +++ /dev/null @@ -1,20 +0,0 @@ -@page "/ingredients/create" -@using CulinaryCommand.Inventory.Entities -@using CulinaryCommand.Inventory.Services -@inject NavigationManager Nav -@inject IngredientService Ingredients -@rendermode InteractiveServer - -

Create Ingredient

- - - -@code { - private Ingredient model = new(); - - private async Task Save() - { - await Ingredients.CreateAsync(model); - Nav.NavigateTo("/ingredients"); - } -} diff --git a/CulinaryCommandApp/Inventory/Pages/Ingredients/Edit.razor b/CulinaryCommandApp/Inventory/Pages/Ingredients/Edit.razor deleted file mode 100644 index 5a4526a..0000000 --- a/CulinaryCommandApp/Inventory/Pages/Ingredients/Edit.razor +++ /dev/null @@ -1,34 +0,0 @@ -@page "/ingredients/edit/{id:int}" -@using CulinaryCommand.Inventory.Entities -@using CulinaryCommand.Inventory.Services -@inject NavigationManager Nav -@inject IngredientService Ingredients -@rendermode InteractiveServer - -

Edit Ingredient

- -@if (model == null) -{ -

Loading...

-} -else -{ - -} - -@code { - [Parameter] public int id { get; set; } - - private Ingredient? model; - - protected override async Task OnInitializedAsync() - { - model = await Ingredients.GetByIdAsync(id); - } - - private async Task Save() - { - await Ingredients.UpdateAsync(model); - Nav.NavigateTo("/ingredients"); - } -} diff --git a/CulinaryCommandApp/Inventory/Pages/Ingredients/Index.razor b/CulinaryCommandApp/Inventory/Pages/Ingredients/Index.razor deleted file mode 100644 index d853509..0000000 --- a/CulinaryCommandApp/Inventory/Pages/Ingredients/Index.razor +++ /dev/null @@ -1,5 +0,0 @@ -@page "/ingredients" -@using CulinaryCommand.Inventory.Entities - - - diff --git a/CulinaryCommandApp/Inventory/Pages/Ingredients/IngredientForm.razor b/CulinaryCommandApp/Inventory/Pages/Ingredients/IngredientForm.razor deleted file mode 100644 index 43e0a65..0000000 --- a/CulinaryCommandApp/Inventory/Pages/Ingredients/IngredientForm.razor +++ /dev/null @@ -1,64 +0,0 @@ -@using CulinaryCommand.Inventory.Entities -@using CulinaryCommand.Inventory.Services -@inject IngredientService Ingredients -@inject UnitService Units -@inject NavigationManager Nav; -@inject EnumService enumService -@rendermode InteractiveServer - - -
-
-

@FormTitle

-
- -
-
- - -
- -
- - -
- -
- - -
- - - -
-
- -@code { - [Parameter] public Ingredient Model { get; set; } = new(); - [Parameter] public string FormTitle { get; set; } = "Ingredient"; - [Parameter] public EventCallback OnValidSubmit { get; set; } - - List UnitsList = new(); - List Categories = new(); - - protected override async Task OnInitializedAsync() - { - UnitsList = await Units.GetAllUnitsAsync(); - Categories = enumService.GetCategories(); - } - - async Task Save() => await OnValidSubmit.InvokeAsync(); - void Cancel() => Nav.NavigateTo("/ingredients"); -} diff --git a/CulinaryCommandApp/Inventory/Pages/Ingredients/IngredientList.razor b/CulinaryCommandApp/Inventory/Pages/Ingredients/IngredientList.razor deleted file mode 100644 index efbec90..0000000 --- a/CulinaryCommandApp/Inventory/Pages/Ingredients/IngredientList.razor +++ /dev/null @@ -1,70 +0,0 @@ -@using CulinaryCommand.Inventory.Entities -@using CulinaryCommand.Inventory.Services -@inject IngredientService Ingredients -@inject NavigationManager Nav -@inject IJSRuntime Js -@rendermode InteractiveServer - -

Ingredients

- - - -@if (items == null) -{ -

Loading...

-} -else -{ - - - - - - - - - - - @foreach (var i in items) - { - - - - - - - } - -
NameCategoryDefault Unit
@i.Name@i.Category@i.Unit?.Abbreviation - - -
-} - -@code { - List? items; - - protected override async Task OnInitializedAsync() - { - // ensure service returns Unit navigation populated - items = await Ingredients.GetAllAsync(); - } - - void AddNew() => Nav.NavigateTo("/ingredients/create"); - void Edit(int id) => Nav.NavigateTo($"/ingredients/edit/{id}"); - - async Task Delete(int id) - { - if (await Js.InvokeAsync("confirm", $"Delete ingredient #{id}?")) - { - await Ingredients.DeleteAsync(id); - items = await Ingredients.GetAllAsync(); - } - } -} diff --git a/CulinaryCommandApp/Inventory/Pages/Ingredients/Ingredients.razor b/CulinaryCommandApp/Inventory/Pages/Ingredients/Ingredients.razor deleted file mode 100644 index 11f18e3..0000000 --- a/CulinaryCommandApp/Inventory/Pages/Ingredients/Ingredients.razor +++ /dev/null @@ -1,121 +0,0 @@ -@* @page "/ingredients" *@ -@using CulinaryCommand.Inventory.Entities -@using CulinaryCommand.Inventory.Models -@using CulinaryCommand.Inventory.Services.Interfaces -@using Microsoft.AspNetCore.Components.Forms -@using System.Linq -@inject IIngredientService IngredientService - -

Ingredients

- - - -@if (editing) -{ - - - - - - - - - -} - - - - - - - - - - - - @foreach (var item in ingredients) - { - - - - - - - } - -
NameCategoryDefault Unit
@item.Name@item.Category@item.Unit?.Abbreviation - -
- -@code { - List ingredients = new(); - IngredientViewModel model = new(); - bool editing = false; - // list of available units for the unit dropdown - List availableUnits = new(); - - protected override async Task OnInitializedAsync() - { - var list = await IngredientService.GetAllAsync(); - ingredients = list.ToList(); - - // build available units from the included Unit navigation - availableUnits = ingredients - .Where(i => i.Unit != null) - .Select(i => i.Unit!) - .GroupBy(u => u.Id) - .Select(g => g.First()) - .OrderBy(u => u.Name) - .ToList(); - } - - void StartAdd() - { - editing = true; - model = new IngredientViewModel(); - } - - void Edit(Ingredient ing) - { - editing = true; - model = new IngredientViewModel { - IngredientId = ing.Id, - Name = ing.Name, - Category = ing.Category, - DefaultUnitId = ing.UnitId - }; - } - - async Task Save() - { - if (model.IngredientId == 0) - { - await IngredientService.CreateAsync(new Ingredient - { - Name = model.Name, - Category = model.Category, - UnitId = model.DefaultUnitId ?? 0 - }); - } - else - { - await IngredientService.UpdateAsync(new Ingredient - { - Id = model.IngredientId, - Name = model.Name, - Category = model.Category, - UnitId = model.DefaultUnitId ?? 0 - }); - } - - var refreshed = await IngredientService.GetAllAsync(); - ingredients = refreshed.ToList(); - editing = false; - } -}