import type { ProjectSummary } from '@/features/projects/types/project.types';

export function useProjectPermissions(project: ProjectSummary | undefined) {
  const p = project?.permissions;
  const readOnly = p ? !p.can_update_work_items : false;

  return {
    role: p?.role ?? null,
    canManage: p?.can_manage ?? false,
    canUpdateWorkItems: p?.can_update_work_items ?? true,
    canPlanCapacity: p?.can_plan_capacity ?? false,
    readOnly,
    isViewer: p?.role === 'viewer',
  };
}
