We are now saving Ingredients!

This commit is contained in:
Kira Jiroux 2025-12-04 12:36:55 -05:00
parent 3feacfaa96
commit 7b6df6530c
4 changed files with 366 additions and 328 deletions

View File

@ -8,7 +8,7 @@ namespace Portfolio.Domain.Features.Pokemon
{ {
public class Ingredient public class Ingredient
{ {
public string Ing { get; set; } public string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }
public string ImageURL { get; set; } public string ImageURL { get; set; }
} }

View File

@ -1,9 +1,14 @@
@inject IPokemonService PokemonService @inject IPokemonService PokemonService
@inject IHttpClientFactory ClientFactory @inject IHttpClientFactory ClientFactory
@if(Ingredients == null)
@if(formUse == "ADD")
{ {
<Loading />
}
else
{
@if(formUse == "ADD")
{
<div class="pokemon-form-container m-auto bg-info border border-5 border-info-subtle rounded-4 p-3"> <div class="pokemon-form-container m-auto bg-info border border-5 border-info-subtle rounded-4 p-3">
<EditForm class="col" Model="NewPokemon"> <EditForm class="col" Model="NewPokemon">
<DataAnnotationsValidator /> <DataAnnotationsValidator />
@ -109,7 +114,37 @@
<option disabled value="" selected>Select...</option> <option disabled value="" selected>Select...</option>
@foreach (var ingredient in Ingredients) @foreach (var ingredient in Ingredients)
{ {
<option value="@ingredient.Ing">@ingredient.Ing</option> <option value="@ingredient.Name">@ingredient.Name</option>
}
</InputSelect>
</div>
</div>
<!-- Ingredient 2 -->
<div class="col ps-0 pe-1">
<div class="row input-group m-auto">
<span for="Ingredient2" class="input-group-text rounded-top">Ingredient 2</span>
</div>
<div class="row input-group m-auto">
<InputSelect id="Ingredient2" @bind-Value="NewPokemon.Ingredient2" @onchange="@SendPokemon" class="form-select rounded-bottom">
<option disabled value="" selected>Select...</option>
@foreach (var ingredient in Ingredients)
{
<option value="@ingredient.Name">@ingredient.Name</option>
}
</InputSelect>
</div>
</div>
<!-- Ingredient 3 -->
<div class="col ps-0 pe-1">
<div class="row input-group m-auto">
<span for="Ingredient3" class="input-group-text rounded-top">Ingredient 3</span>
</div>
<div class="row input-group m-auto">
<InputSelect id="Ingredient3" @bind-Value="NewPokemon.Ingredient3" @onchange="@SendPokemon" class="form-select rounded-bottom">
<option disabled value="" selected>Select...</option>
@foreach (var ingredient in Ingredients)
{
<option value="@ingredient.Name">@ingredient.Name</option>
} }
</InputSelect> </InputSelect>
</div> </div>
@ -189,9 +224,9 @@
</EditForm> </EditForm>
</div> </div>
} }
else if (formUse == "EDIT") else if (formUse == "EDIT")
{ {
<div class="pokemon-form-container m-auto bg-info border border-5 border-info-subtle rounded-4 p-3"> <div class="pokemon-form-container m-auto bg-info border border-5 border-info-subtle rounded-4 p-3">
<EditForm class="col" Model="PokemonToEdit"> <EditForm class="col" Model="PokemonToEdit">
<DataAnnotationsValidator /> <DataAnnotationsValidator />
@ -335,5 +370,6 @@ else if (formUse == "EDIT")
</div> </div>
</EditForm> </EditForm>
</div> </div>
}
} }

View File

@ -29,10 +29,7 @@ namespace Portfolio.WebUI.Server.Components.Component.Pokemon_Components
PokemonName = string.Empty, // Required fields cannot be null PokemonName = string.Empty, // Required fields cannot be null
SleepType = string.Empty, SleepType = string.Empty,
Speciality = string.Empty, Speciality = string.Empty,
IsVariation = false, IsVariation = false
Ingredient1 = "",
Ingredient2 = "",
Ingredient3 = ""
}; };
// When Editing // When Editing
@ -43,8 +40,6 @@ namespace Portfolio.WebUI.Server.Components.Component.Pokemon_Components
// General Form // General Form
private List<string> PokemonTypeInfo;
protected static readonly string[] PokemonTypes = new[] protected static readonly string[] PokemonTypes = new[]
{ {
"Grass","Fire","Water","Normal","Flying","Bug","Poison","Electric","Ground","Rock","Ice", "Grass","Fire","Water","Normal","Flying","Bug","Poison","Electric","Ground","Rock","Ice",
@ -52,8 +47,8 @@ namespace Portfolio.WebUI.Server.Components.Component.Pokemon_Components
}; };
protected static readonly string[] SleepTypes = new[] { "Dozing", "Snoozing", "Slumbering" }; protected static readonly string[] SleepTypes = new[] { "Dozing", "Snoozing", "Slumbering" };
protected static readonly string[] Specialities = new[] { "Berries", "Ingredients", "Skills", "All" }; protected static readonly string[] Specialities = new[] { "Berries", "Ingredients", "Skills", "All" };
private List<Ingredient> Ingredients { get; set; }
private List<Ingredient>? Ingredients;
private bool HideLabel { get; set; } private bool HideLabel { get; set; }
private bool showErrors { get; set; } = false; private bool showErrors { get; set; } = false;
@ -126,6 +121,7 @@ namespace Portfolio.WebUI.Server.Components.Component.Pokemon_Components
private async Task SendPokemon() private async Task SendPokemon()
{ {
Console.WriteLine("onchange");
if(formUse == "ADD") if(formUse == "ADD")
{ {
if (!IsComplete) if (!IsComplete)
@ -147,7 +143,10 @@ namespace Portfolio.WebUI.Server.Components.Component.Pokemon_Components
VariationName = NewPokemon.VariationName, VariationName = NewPokemon.VariationName,
PokemonImageUrl = NewPokemon.PokemonImageUrl, PokemonImageUrl = NewPokemon.PokemonImageUrl,
PokemonShinyImageUrl = NewPokemon.PokemonShinyImageUrl, PokemonShinyImageUrl = NewPokemon.PokemonShinyImageUrl,
FlavorText = NewPokemon.FlavorText FlavorText = NewPokemon.FlavorText,
Ingredient1 = NewPokemon.Ingredient1,
Ingredient2 = NewPokemon.Ingredient2,
Ingredient3 = NewPokemon.Ingredient3
}; };
await OnPokemonReady.InvokeAsync(copy); await OnPokemonReady.InvokeAsync(copy);
@ -168,7 +167,10 @@ namespace Portfolio.WebUI.Server.Components.Component.Pokemon_Components
VariationName = PokemonToEdit.VariationName, VariationName = PokemonToEdit.VariationName,
PokemonImageUrl = PokemonToEdit.PokemonImageUrl, PokemonImageUrl = PokemonToEdit.PokemonImageUrl,
PokemonShinyImageUrl = PokemonToEdit.PokemonShinyImageUrl, PokemonShinyImageUrl = PokemonToEdit.PokemonShinyImageUrl,
FlavorText = PokemonToEdit.FlavorText FlavorText = PokemonToEdit.FlavorText,
Ingredient1 = PokemonToEdit.Ingredient1,
Ingredient2 = PokemonToEdit.Ingredient2,
Ingredient3 = PokemonToEdit.Ingredient3
}; };
await OnPokemonReady.InvokeAsync(edit); await OnPokemonReady.InvokeAsync(edit);

View File

@ -1,98 +1,98 @@
[ [
{ {
"ingredient": "Large Leek", "name": "Large Leek",
"description": "Whether this is the kind of vegetable stalk that Farfetch'd like is unknown.", "description": "Whether this is the kind of vegetable stalk that Farfetch'd like is unknown.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/largeleek.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/largeleek.png"
}, },
{ {
"ingredient": "Tasty Mushroom", "name": "Tasty Mushroom",
"description": "A juicy mushroom with an abundance of umami flavor.", "description": "A juicy mushroom with an abundance of umami flavor.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/tastymushroom.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/tastymushroom.png"
}, },
{ {
"ingredient": "Fancy Egg", "name": "Fancy Egg",
"description": "A nutritious cooking ingredient that goes well with all sorts of seasonings.", "description": "A nutritious cooking name that goes well with all sorts of seasonings.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/fancyegg.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/fancyegg.png"
}, },
{ {
"ingredient": "Soft Potato", "name": "Soft Potato",
"description": "Its mellow flavor makes both body and spirit feel warm and fuzzy.", "description": "Its mellow flavor makes both body and spirit feel warm and fuzzy.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/softpotato.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/softpotato.png"
}, },
{ {
"ingredient": "Fancy Apple", "name": "Fancy Apple",
"description": "An apple chosen above others. It has spectacular form and a brilliant sheen.", "description": "An apple chosen above others. It has spectacular form and a brilliant sheen.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/fancyapple.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/fancyapple.png"
}, },
{ {
"ingredient": "Fiery Herb", "name": "Fiery Herb",
"description": "The fiery taste of this bright-red herb will wake anyone right up.", "description": "The fiery taste of this bright-red herb will wake anyone right up.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/fieryherb.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/fieryherb.png"
}, },
{ {
"ingredient": "Bean Sausage", "name": "Bean Sausage",
"description": "A healthy sausage made from beans that Pok<6F>mon like to eat.", "description": "A healthy sausage made from beans that Pok<6F>mon like to eat.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/beansausage.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/beansausage.png"
}, },
{ {
"ingredient": "Moomoo Milk", "name": "Moomoo Milk",
"description": "Highly nutritious milk. Pok<6F>mon that drink it become full of energy.", "description": "Highly nutritious milk. Pok<6F>mon that drink it become full of energy.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/moomoomilk.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/moomoomilk.png"
}, },
{ {
"ingredient": "Honey", "name": "Honey",
"description": "A sweet honey collected by Pok<6F>mon.", "description": "A sweet honey collected by Pok<6F>mon.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/honey.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/honey.png"
}, },
{ {
"ingredient": "Pure Oil", "name": "Pure Oil",
"description": "All-purpose oil that can be used in any type of cuisine.", "description": "All-purpose oil that can be used in any type of cuisine.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/pureoil.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/pureoil.png"
}, },
{ {
"ingredient": "Warming Ginger", "name": "Warming Ginger",
"description": "Spicy ginger that warms the body better than any other ingredient.", "description": "Spicy ginger that warms the body better than any other name.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/warmingginger.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/warmingginger.png"
}, },
{ {
"ingredient": "Snoozy Tomato", "name": "Snoozy Tomato",
"description": "A bright-red tomato. Eat it and you'll sleep like a baby.", "description": "A bright-red tomato. Eat it and you'll sleep like a baby.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/snoozytomato.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/snoozytomato.png"
}, },
{ {
"ingredient": "Soothing Cacao", "name": "Soothing Cacao",
"description": "This cacao bean is time-consuming to process, but its soothing effects make the effort worthwhile.", "description": "This cacao bean is time-consuming to process, but its soothing effects make the effort worthwhile.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/soothingcacao.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/soothingcacao.png"
}, },
{ {
"ingredient": "Slowpoke Tail", "name": "Slowpoke Tail",
"description": "A very tasty tail of something. When it falls off, it grows back quickly.", "description": "A very tasty tail of something. When it falls off, it grows back quickly.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/slowpoketail.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/slowpoketail.png"
}, },
{ {
"ingredient": "Greengrass Soybeans", "name": "Greengrass Soybeans",
"description": "This Greengrass Isle specialty is easy to process into foods that are great for training.", "description": "This Greengrass Isle specialty is easy to process into foods that are great for training.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/greengrasssoybeans.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/greengrasssoybeans.png"
}, },
{ {
"ingredient": "Greengrass Corn", "name": "Greengrass Corn",
"description": "This Greengrass Isle specialty can be eaten raw. It's remarkably sweet.", "description": "This Greengrass Isle specialty can be eaten raw. It's remarkably sweet.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/greengrasscorn.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/greengrasscorn.png"
}, },
{ {
"ingredient": "Rousing Coffee", "name": "Rousing Coffee",
"description": "You may have trouble sleeping if you drink too much of this. It may help make you feel more alert.", "description": "You may have trouble sleeping if you drink too much of this. It may help make you feel more alert.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/rousingcoffee.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/rousingcoffee.png"
}, },
{ {
"ingredient": "Plump Pumpkin", "name": "Plump Pumpkin",
"description": "A big pumpkin packed full of pulp.", "description": "A big pumpkin packed full of pulp.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/plumppumpkin.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/plumppumpkin.png"
}, },
{ {
"ingredient": "Glossy Avocado", "name": "Glossy Avocado",
"description": "The glossy green shine is a sign it' s freshly picked.", "description": "The glossy green shine is a sign it' s freshly picked.",
"imageURL": "https://www.serebii.net/pokemonsleep/ingredients/glossyavocado.png" "imageURL": "https://www.serebii.net/pokemonsleep/names/glossyavocado.png"
} }
] ]