diff --git a/Portfolio.WebUI.Server/Components/Pages/PokemonCreate.razor b/Portfolio.WebUI.Server/Components/Pages/PokemonCreate.razor index 7ee699d..e6309f2 100644 --- a/Portfolio.WebUI.Server/Components/Pages/PokemonCreate.razor +++ b/Portfolio.WebUI.Server/Components/Pages/PokemonCreate.razor @@ -1,61 +1,105 @@ @page "/pokemonsleep/add-new-pokemon" + @inject IPokemonService PokemonService @inject NavigationManager Navigation -

Add New Pokémon

+@attribute [StreamRendering] +@rendermode InteractiveServer + +Add New Pokémon + +
+
+
+

Pokémon Sleep

+
+
+
@if (isSubmitting) {

Submitting...

} else { -
- - -
- - +
+ +
+
+
+

Add New Pokémon

+
+
-
- - -
-
- - -
-
- - -
-
- - - - - - -
+
+ + -
- - - - - - -
+ +
+
+ + # + + + +
+
- - -
-
+ +
+
+ + + Variation? + +
+
+ + + +
+ + + + + + + +
+ + +
+ + + + + + + +
+ + + +
+
} + + + + @code { + + private bool HideLabel { get; set; } = true; + private void Toggle() + { + HideLabel = !HideLabel; + } + private Pokemon NewPokemon = new Pokemon { PokemonId = 0, // Or any default ID logic diff --git a/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor b/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor index 097ef86..7f9fc99 100644 --- a/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor +++ b/Portfolio.WebUI.Server/Components/Pages/PokemonSleep.razor @@ -3,124 +3,149 @@ @inject IPokemonService PokemonService @attribute [StreamRendering] +@rendermode InteractiveServer + +Pokémon Sleep + + + +
+
+
+
+

Pokémon Sleep

+
+
+ + + + + Add New Pokemon + +
+
+
-Pokemon Sleep -

Pokemon Sleep

@if (pokemons == null) {

Loading...

} else { -
-
-
-
-

Available Pokemon

-
-
-
-
-
-
-
-
- - - - - Add New Pokemon - -
-
+
+
+
+
+

Available Pokémon

+
+
+
+
+ + + + + + + + + + + + + @foreach (var pokemon in pokemons) + { + - -
#PokemonSleep TypeSpeciality
- - - - - - - - - - - - @foreach (var pokemon in pokemons) - { - - @if (pokemon.IsVariation) - { - @if (pokemon.VariationName == "Alolan") + + @if (pokemon.IsVariation) { + @if (pokemon.VariationName == "Alolan") + { string URL = $"/pokemon_images/normal/{pokemon.PokemonId}-{pokemon.VariationName.ToLower()}{pokemon.PokemonName.ToLower()}.png"; string ShinyURL = $"/pokemon_images/shiny/{pokemon.PokemonId}-{pokemon.VariationName.ToLower()}{pokemon.PokemonName.ToLower()}.png"; - } - @if (pokemon.VariationName == "Paldean") - { + } + @if (pokemon.VariationName == "Paldean") + { string URL = $"/pokemon_images/normal/{pokemon.PokemonId}-{pokemon.VariationName.ToLower()}{pokemon.PokemonName.ToLower()}.png"; string ShinyURL = $"/pokemon_images/shiny/{pokemon.PokemonId}-{pokemon.VariationName.ToLower()}{pokemon.PokemonName.ToLower()}.png"; + } } - } - else // Base Case - { - string URL = $"/pokemon_images/normal/{pokemon.PokemonId}.png"; ; - string ShinyURL = $"/pokemon_images/shiny/{pokemon.PokemonId}.png"; - - } - - - - @if (pokemon.IsVariation) - { - @if (pokemon.VariationName == "Alolan") + else // Base Case { - + string URL = $"/pokemon_images/normal/{pokemon.PokemonId}.png"; ; + string ShinyURL = $"/pokemon_images/shiny/{pokemon.PokemonId}.png"; + } - @if (pokemon.VariationName == "Paldean") + + + + + + @if (pokemon.IsVariation) // If a Variant { - + @if (pokemon.VariationName == "Alolan") + { + + } + @if (pokemon.VariationName == "Paldean") + { + + } } - } - else // Base Case - { + else // Otherwise, Base Case + { - } + } + + - - - - - } - -
#PokemonSleep TypeSpeciality
- - - @pokemon.PokemonId Alolan @pokemon.PokemonName + + + @pokemon.PokemonId Paldean @pokemon.PokemonName Alolan @pokemon.PokemonName Paldean @pokemon.PokemonName @pokemon.PokemonName@pokemon.SleepType@pokemon.SleepType@pokemon.Speciality - - + + @pokemon.Speciality + + + + + - - - + + +
-
+ + } + + +
} @@ -128,7 +153,6 @@ else @code { private List pokemons = new List(); - private bool showForm = true; protected override async Task OnInitializedAsync() @@ -138,8 +162,10 @@ else if (result is not null) { pokemons = result; + pokemons.Sort((x,y) => x.PokemonId.CompareTo(y.PokemonId)); } } + } diff --git a/Portfolio.WebUI.Server/Program.cs b/Portfolio.WebUI.Server/Program.cs index 0369665..47899c0 100644 --- a/Portfolio.WebUI.Server/Program.cs +++ b/Portfolio.WebUI.Server/Program.cs @@ -5,7 +5,8 @@ using Portfolio.Infrastructure; var builder = WebApplication.CreateBuilder(args); // Add services to the container. -builder.Services.AddRazorComponents(); +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); builder.Services.AddApplication(); builder.Services.AddInfrastructure(builder.Configuration); @@ -25,6 +26,7 @@ app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); -app.MapRazorComponents(); +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); app.Run();