<?php

namespace App\Http\Controllers\Api\User;

use App\Http\Controllers\Controller;
use App\Services\Shared\ThemeService;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;

class UserThemeController extends Controller
{
    protected $themeService;

    public function __construct(ThemeService $themeService)
    {
        $this->themeService = $themeService;
    }

    public function update(Request $request): JsonResponse
    {
        $request->validate([
            'theme' => 'required|in:light,dark,system',
        ]);

        $this->themeService->updateTheme($request->user(), $request->theme);

        return response()->json([
            'success' => true,
            'message' => 'User theme updated successfully via API',
            'theme' => $request->theme
        ]);
    }
}