<?php

namespace App\Filament\Widgets;

use App\Models\Booking;
use App\Models\Event;
use App\Models\Ride;
use Filament\Widgets\ChartWidget;

class FunnelStageChart extends ChartWidget
{
    protected static ?string $heading = 'Embudo TAXILANZ';

    protected function getData(): array
    {
        $rides = Ride::count();
        $views = Event::where('event_type', 'recommendation_viewed')->count();
        $clicks = Event::where('event_type', 'recommendation_clicked')->count();
        $bookings = Booking::count();

        return [
            'datasets' => [[
                'label' => 'Eventos del funnel',
                'data' => [$rides, $views, $clicks, $bookings],
                'backgroundColor' => ['#0f766e', '#14b8a6', '#f59e0b', '#16a34a'],
                'borderRadius' => 10,
                'borderSkipped' => false,
            ]],
            'labels' => ['Taxi requests', 'Recommendation views', 'Clicks', 'Bookings'],
        ];
    }

    protected function getType(): string
    {
        return 'bar';
    }
}
