import type { Access, ClientUser } from 'payload'

export const isAdmin =
  (): Access =>
  ({ req: { user } }) => {
    return user?.roles === 'admin'
  }

export const isAdminOrEmployee =
  (): Access =>
  ({ req: { user } }) => {
    if (!user) {
      return false
    }

    return user.roles === 'admin' || user.roles === 'employee'
  }

export const hide = (args: {   user: ClientUser }) => args.user && args.user.roles === "user"