@page "/pokemon-sleep/add-new-pokemon"

@inject IPokemonService PokemonService
@inject NavigationManager Navigation

@inject IJSRuntime JS

@attribute [StreamRendering]
@rendermode InteractiveServer


<PageTitle>Add New Pokémon</PageTitle>
<PokemonNavMenu />


@if (isSubmitting)
{
    <p><em>Submitting...</em></p>
}
else
{
    <div class="container">
        <div class="row mt-3">
            <div class="d-flex justify-content-evenly p-0">

                <div class="mx-1 align-content-center">
                    <div class="addcard">
                        <PokemonForm 
                            formUse="ADD"
                            OnPokemonReady="ReceivePokemon1" 
                            mostRecentForm=false
                        />
                    </div>
                </div>


                @if(!pokemon2FormView && !pokemon3FormView)
                {
                    <div class="mx-1 align-content-center">
                        <PokemonAddButton OnAdd="TogglePokemon2FormView" />
                     </div>
                }


                else if (pokemon2FormView && !pokemon3FormView)
                {
                    <div class="mx-1 align-content-center">
                        <div class="addcard">
                            <PokemonForm OnPokemonReady="ReceivePokemon2"
                                formUse="ADD"
                                RemoveForm="TogglePokemon2FormView"
                                mostRecentForm="@pokemon2FormView" />
                        </div>
                    </div>
                    <div class="mx-1 align-content-center">
                        <PokemonAddButton OnAdd="TogglePokemon3FormView" />
                    </div>
                }


                else if (!pokemon2FormView && pokemon3FormView)
                {
                    <div class="mx-1 align-content-center">
                        <div class="addcard">
                            <PokemonForm OnPokemonReady="ReceivePokemon2"
                                formUse="ADD"
                                RemoveForm="TogglePokemon2FormView"
                                mostRecentForm="@pokemon2FormView" />
                        </div>
                    </div>
                    <div class="mx-1 align-content-center">
                        <div class="addcard">
                            <PokemonForm OnPokemonReady="ReceivePokemon3"
                                formUse="ADD"
                                RemoveForm="TogglePokemon3FormView"
                                mostRecentForm="@pokemon3FormView" />
                        </div>
                    </div>
                }


            </div>
        </div>
    </div>

    <div class="d-flex justify-content-center mt-5">
        <div class="btn-group">
            <button @onclick="@HandleAdd" class="btn btn-primary rounded">Add Pokemon</button>
        </div>
    </div>
}


