export const getCurrentUser = () => ({
  id: Number(localStorage.getItem('precision_user_id') || 0),
  name: localStorage.getItem('precision_user_name') || '',
  role: localStorage.getItem('precision_user_role') || '',
})

export const getCurrentRole = () => {
  const role = getCurrentUser().role
  if (['系统管理员', '管理员', 'admin'].includes(role)) return 'admin'
  return 'user'
}

export const isAdmin = () => getCurrentRole() === 'admin'

export const canEditData = () => isAdmin()
