<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Services\TenantOptionValueService;
use Illuminate\Http\Request;

class TenantOptionValueController extends Controller
{
    // GET /v1/opt-groups/{gid}/values
    public function index(Request $request, $gid)
    {
        return ApiResponse::handle(function () use ($request, $gid) {
            return TenantOptionValueService::index($gid, $request->all());
        }, '옵션 값 목록 조회');
    }

    // POST /v1/opt-groups/{gid}/values
    public function store(Request $request, $gid)
    {
        return ApiResponse::handle(function () use ($request, $gid) {
            return TenantOptionValueService::store($gid, $request->all());
        }, '옵션 값 생성');
    }

    // GET /v1/opt-groups/{gid}/values/{id}
    public function show($gid, $id)
    {
        return ApiResponse::handle(function () use ($gid, $id) {
            return TenantOptionValueService::show($gid, $id);
        }, '옵션 값 단건 조회');
    }

    // PATCH /v1/opt-groups/{gid}/values/{id}
    public function update(Request $request, $gid, $id)
    {
        return ApiResponse::handle(function () use ($request, $gid, $id) {
            return TenantOptionValueService::update($gid, $id, $request->all());
        }, '옵션 값 수정');
    }

    // DELETE /v1/opt-groups/{gid}/values/{id}
    public function destroy($gid, $id)
    {
        return ApiResponse::handle(function () use ($gid, $id) {
            return TenantOptionValueService::destroy($gid, $id);
        }, '옵션 값 삭제');
    }

    // PATCH /v1/opt-groups/{gid}/values/reorder
    public function reorder(Request $request, $gid)
    {
        return ApiResponse::handle(function () use ($request, $gid) {
            return TenantOptionValueService::reorder($gid, $request->all());
        }, '옵션 값 정렬 순서 변경');
    }
}
