<?php

namespace App\Modules\Navigation\Services;

use App\Models\User;
use App\Modules\Settings\Rbac\Services\TenantPermissionEvaluator;

class HomeRouteResolver
{
    public function __construct(
        private readonly TenantPermissionEvaluator $permissions,
    ) {}

    public function name(User $user): string
    {
        if ($user->isAdmin() || $user->isTenantOwner() || $this->permissions->hasAnyAbility($user)) {
            return 'dashboard.index';
        }

        if ($user->employee_id !== null) {
            return 'me.dashboard';
        }

        return 'dashboard.index';
    }
}
