<?php

namespace App\Http\Controllers;

use App\Http\Requests\Auth\CompleteProfileRequest;
use App\Services\ProfileCompletionService;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;

class ProfileCompletionController extends Controller
{
    public function edit(): Response
    {
        return Inertia::render('Auth/CompleteProfile', [
            'requiredFields' => app(ProfileCompletionService::class)->requiredFieldsForUser(request()->user()),
        ]);
    }

    public function update(CompleteProfileRequest $request, ProfileCompletionService $service): RedirectResponse
    {
        $service->complete($request->user(), $request->validated());

        return redirect()->route('dashboard')->with('success', 'اطلاعات شما تکمیل شد.');
    }
}
