@page "/test"

@using System.Net;
@using PanoptesFrontend.Data
@using PanoptesFrontend.Services
@using System.Text.Json;
@inject IHttpService httpService

@if (data != null)
{
    @foreach (var component in data) {
        switch (component.Type) {
        case 0:
            <TestCard Data="@component" />
            break;
        case 1:
            <ApexChart TItem="Stats"
                    Title="Order Gross Value">

                <ApexPointSeries TItem="Stats"
                            Items=component.Stats
                            SeriesType="SeriesType.Donut"
                            Name="Gross Value"
                            XValue="@(e => e.Label)"
                            YValue="@(e => e.Value)"
                            OrderByDescending="e=>e.Y" />
            </ApexChart>
            break;
        }
        
    }
}


@code {
    private Component[] data;



    protected override async Task OnInitializedAsync()
    {
        var response = await httpService.GetAsync<Schema>("http://localhost:10000/localhost:8080/schema");
        data = response.components;
    }

}

