<?php

namespace App\Http\Controllers\HR;

use App\Http\Controllers\Controller;
use App\Services\HR\EmployeeService;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class EmployeeTenureController extends Controller
{
    public function __construct(
        private EmployeeService $employeeService
    ) {}

    /**
     * 입퇴사자 현황 페이지
     */
    public function index(Request $request): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('hr.employee-tenure'));
        }

        $stats = $this->employeeService->getTenureStats();
        $departments = $this->employeeService->getDepartments();

        return view('hr.employee-tenure.index', [
            'stats' => $stats,
            'departments' => $departments,
        ]);
    }
}
