<?php

namespace App\Livewire;

use App\Services\DashboardStatsService;
use Illuminate\Contracts\View\View;
use Livewire\Component;

class Dashboard extends Component
{
    public string $period = 'today';

    public function mount(): void
    {
        // Default period
    }

    public function setPeriod(string $period): void
    {
        $this->period = $period;
    }

    public function render(): View
    {
        $service = app(DashboardStatsService::class);

        $articleStats = $service->getStats($this->period);
        $systemStats = $service->getSystemStats();
        $availablePeriods = $service->getAvailablePeriods();

        return view('livewire.dashboard', [
            'articleStats' => $articleStats,
            'systemStats' => $systemStats,
            'availablePeriods' => $availablePeriods,
        ])->layout('layouts.app');
    }
}
