<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\V1\WorkSetting\UpdateAttendanceSettingRequest;
use App\Http\Requests\V1\WorkSetting\UpdateWorkSettingRequest;
use App\Services\WorkSettingService;

class WorkSettingController extends Controller
{
    public function __construct(
        private readonly WorkSettingService $service
    ) {}

    /**
     * 근무 설정 조회
     */
    public function showWorkSetting()
    {
        $setting = $this->service->getWorkSetting();

        return ApiResponse::success($setting, __('message.fetched'));
    }

    /**
     * 근무 설정 수정
     */
    public function updateWorkSetting(UpdateWorkSettingRequest $request)
    {
        $setting = $this->service->updateWorkSetting($request->validated());

        return ApiResponse::success($setting, __('message.updated'));
    }

    /**
     * 출퇴근 설정 조회
     */
    public function showAttendanceSetting()
    {
        $setting = $this->service->getAttendanceSetting();

        return ApiResponse::success($setting, __('message.fetched'));
    }

    /**
     * 출퇴근 설정 수정
     */
    public function updateAttendanceSetting(UpdateAttendanceSettingRequest $request)
    {
        $setting = $this->service->updateAttendanceSetting($request->validated());

        return ApiResponse::success($setting, __('message.updated'));
    }
}
