<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\V1\Dashboard\DashboardApprovalsRequest;
use App\Http\Requests\V1\Dashboard\DashboardChartsRequest;
use App\Services\DashboardService;
use Illuminate\Http\JsonResponse;

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

    /**
     * 대시보드 요약 데이터 조회
     */
    public function summary(): JsonResponse
    {
        $data = $this->dashboardService->summary();

        return ApiResponse::handle(['data' => $data], __('message.fetched'));
    }

    /**
     * 대시보드 차트 데이터 조회
     */
    public function charts(DashboardChartsRequest $request): JsonResponse
    {
        $data = $this->dashboardService->charts($request->validated());

        return ApiResponse::handle(['data' => $data], __('message.fetched'));
    }

    /**
     * 결재 현황 조회
     */
    public function approvals(DashboardApprovalsRequest $request): JsonResponse
    {
        $data = $this->dashboardService->approvals($request->validated());

        return ApiResponse::handle(['data' => $data], __('message.fetched'));
    }
}
