import { ErrorMessage as RHFErrorMessage } from "@hookform/error-message"

import Body from "@/components/TempDesignSystem/Text/Body"

import styles from "./error.module.css"

import type { ErrorMessageProps } from "./errorMessage"

export default function ErrorMessage<T>({
  errors,
  name,
}: ErrorMessageProps<T>) {
  return (
    <RHFErrorMessage
      errors={errors}
      name={name}
      render={({ message }) => (
        <Body className={styles.message} fontOnly>
          {message}
        </Body>
      )}
    />
  )
}
