import React from 'react'; import { FormikErrors, FormikTouched } from 'formik'; import tw from 'twin.macro'; import { capitalize } from '@/lib/strings'; interface Props { errors: FormikErrors; touched: FormikTouched; name: string; children?: string | number | null | undefined; } const InputError = ({ errors, touched, name, children }: Props) => touched[name] && errors[name] ? (

{typeof errors[name] === 'string' ? capitalize(errors[name] as string) : capitalize((errors[name] as unknown as string[])[0])}

) : ( <>{children ?

{children}

: null} ); export default InputError;