<?php

namespace App\Modules\HR\Performance\Services;

use App\Modules\HR\Performance\Models\PerformanceReview;
use App\Modules\HR\Performance\Repositories\PerformanceRepository;

class PerformanceService
{
    public function __construct(private readonly PerformanceRepository $repository) {}

    public function selfUpdate(PerformanceReview $review, array $data): PerformanceReview
    {
        return $this->repository->saveReview((int) $review->tenant_id, $data + ['status' => 'self_submitted'], $review);
    }

    public function managerUpdate(PerformanceReview $review, array $data, int $userId): PerformanceReview
    {
        return $this->repository->saveReview((int) $review->tenant_id, $data + [
            'status' => 'manager_reviewed', 'reviewed_by' => $userId, 'reviewed_at' => now(),
        ], $review);
    }
}
