import { computed } from 'vue'
import { usePermissionStore } from 'stores/permissionStore'

export function usePermission () {

  const perm = usePermissionStore()

  return {

    canRead:  (m) => computed(() => perm.hasPermission(m, 'read')),
    canWrite: (m) => computed(() => perm.hasPermission(m, 'write')),
    canUpdate:(m) => computed(() => perm.hasPermission(m, 'update')),
    canDelete:(m) => computed(() => perm.hasPermission(m, 'delete')),
    canExport:(m) => computed(() => perm.hasPermission(m, 'export')),

    canApi: (p) => computed(() => perm.hasApiPermission(p)),

    hasModule: (m) => computed(() => perm.hasModule(m))
  }
}
