Skip to content
Discussion options

You must be logged in to vote

I figured it out if someone a better way to accomplish this please let me know.

Create a custom select component

'use client'

import * as React from 'react'
import { SelectInput, useAuth, useField } from '@payloadcms/ui'

type CustomSelectProps = {
  path: string
  options: {
    label: string
    value: string
  }[]
}

const CustomSelectComponent: React.FC<CustomSelectProps> = ({ path }) => {
  const { value, setValue } = useField<string>({ path })
  const { user } = useAuth()

  const [options, setOptions] = React.useState<{ label: string; value: string }[]>([
    { label: 'Agent', value: 'agent' },
  ])

  React.useEffect(() => {
    if (user?.roles.includes('admin')) {
      setOptions(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gorillah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant