using Portfolio.Application.Services.PokemonService;
using Portfolio.Domain.Features.Pokemon;

namespace Portfolio.WebUI.Server.Components.Pages.Pokemon_Pages
{
    public partial class PokemonView
    {
        public List<Pokemon> pokemons = new List<Pokemon>();
        public List<string> pokemonImageUrls = new List<string>();
        public List<string> pokemonShinyImageUrls = new List<string>();


        protected override async Task OnInitializedAsync()
        {
            var result = await PokemonService.GetAllPokemonAsync();
            if (result is not null)
            {
                pokemons = result;
                pokemons.Sort((x, y) => x.PokemonId.CompareTo(y.PokemonId));

                foreach (var pokemon in pokemons)
                {
                    pokemonImageUrls.Add(pokemon.PokemonImageUrl);
                    pokemonShinyImageUrls.Add(pokemon.PokemonShinyImageUrl);
                }

            }
        }
    }
}
