package com.example.views;

import com.example.components.BarChart;
import com.example.components.Card;
import com.example.components.LineChart;
import com.example.components.PieChart;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;

import java.util.List;

@Route("")
@PageTitle("Dashboard")
public class DashboardView extends VerticalLayout {

    public DashboardView() {
        addClassName("dialect-content");

        LineChart lineChart = new LineChart();
        lineChart.setWidthFull();
        lineChart.setHeight("400px");
        lineChart.setData("Umsatz 2026",
                List.of(30.0, 40.0, 35.0, 50.0, 49.0, 60.0),
                List.of("Jan", "Feb", "Mär", "Apr", "Mai", "Jun"));
        lineChart.addPointClickListener(e -> {
            Notification.show("Serie %d, Punkt %d"
                    .formatted(e.getSeriesIndex(), e.getDataPointIndex()));
        });

        BarChart barChart = new BarChart();
        barChart.setWidthFull();
        barChart.setHeight("400px");
        barChart.setData("Umsatz 2026",
                List.of(30.0, 40.0, 35.0, 50.0, 49.0, 60.0),
                List.of("Jan", "Feb", "Mär", "Apr", "Mai", "Jun"));
        barChart.addPointClickListener(e -> {
            Notification.show("Serie %d, Punkt %d"
                    .formatted(e.getSeriesIndex(), e.getDataPointIndex()));
        });

        PieChart pieChart = new PieChart();
        pieChart.setWidthFull();
        pieChart.setHeight("400px");
        pieChart.setData(
                List.of(30.0, 40.0, 35.0, 50.0),
                List.of("Nord", "Süd", "Ost", "West"));
        pieChart.addPointClickListener(e -> {
            Notification.show("Slice %d".formatted(e.getDataPointIndex()));
        });

        add(new Card("Umsatz-Entwicklung", lineChart),
                new Card("Umsatz nach Monat", barChart),
                new Card("Umsatz nach Region", pieChart));
    }
}
