<?php

namespace App\Policies;

use App\Models\TeamMember;
use App\Models\User;

class TeamMemberPolicy
{
    /**
     * Determine whether the user can view any models.
     */
    public function viewAny(User $user): bool
    {
        // All authenticated users can view team members
        return true;
    }

    /**
     * Determine whether the user can view the model.
     */
    public function view(User $user, TeamMember $teamMember): bool
    {
        // All authenticated users can view individual team members
        return true;
    }

    /**
     * Determine whether the user can create models.
     */
    public function create(User $user): bool
    {
        // Only superusers and managers can create team members
        return in_array($user->role, ['superuser', 'manager']);
    }

    /**
     * Determine whether the user can update the model.
     */
    public function update(User $user, TeamMember $teamMember): bool
    {
        // Only superusers and managers can update team members
        return in_array($user->role, ['superuser', 'manager']);
    }

    /**
     * Determine whether the user can delete the model.
     */
    public function delete(User $user, TeamMember $teamMember): bool
    {
        // Only superusers and managers can delete team members
        return in_array($user->role, ['superuser', 'manager']);
    }

    /**
     * Determine whether the user can restore the model.
     */
    public function restore(User $user, TeamMember $teamMember): bool
    {
        // Only superusers and managers can restore team members
        return in_array($user->role, ['superuser', 'manager']);
    }

    /**
     * Determine whether the user can permanently delete the model.
     */
    public function forceDelete(User $user, TeamMember $teamMember): bool
    {
        // Only superusers can force delete team members
        return $user->role === 'superuser';
    }

    /**
     * Determine whether the user can view utilization data.
     *
     * All authenticated users can view utilization data.
     */
    public function viewUtilization(User $user): bool
    {
        return true;
    }

    /**
     * Determine whether the user can view running utilization.
     */
    public function viewRunningUtilization(User $user): bool
    {
        return true;
    }

    /**
     * Determine whether the user can view overall utilization.
     */
    public function viewOverallUtilization(User $user): bool
    {
        return true;
    }

    /**
     * Determine whether the user can view team utilization.
     */
    public function viewTeamUtilization(User $user): bool
    {
        return true;
    }

    /**
     * Determine whether the user can view team running utilization.
     */
    public function viewTeamRunningUtilization(User $user): bool
    {
        return true;
    }

    /**
     * Determine whether the user can view utilization trend.
     */
    public function viewUtilizationTrend(User $user): bool
    {
        return true;
    }
}
