import type { FC } from 'react'

type Props = { id?:        string
	       messages?:  string[] }


export const FieldError: FC<Props> = ({ id, messages }: Props) => {
  if (!(messages) || messages.length === 0)
    return null

  return (
      <ul id={id} className="mt-1 space-y-1 text-red-700 dark:text-red-300">
	{messages.map ((message, i) => <li key={i}>{message}</li>)}
      </ul>)
}


export default FieldError
