<?php

namespace App\Http\Controllers;

use App\Services\DashboardService;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

class DashboardController extends Controller
{
    public function __construct(
        private DashboardService $service
    ) {}

    public function __invoke(Request $request): Response
    {
        $user = $request->user();

        return Inertia::render('dashboard', [
            'attendance' =>  $this->service->getAttendanceStats(),
            'revenueSummary' => $this->service->getRevenueSummary(),
            'expenseSummary' => $this->service->getExpenseSummary(),
            'orderStats' => $this->service->getOrderStats(),
            'todayAttendance' =>  $this->service->getTodayAttendance($user),
            'isOnLeave' => $this->service->isOnLeave($user),
            'canCheckIn' => $user->employee !== null,
        ]);
    }
}
