Path: blob/1.0-develop/resources/scripts/components/elements/InputError.tsx
7461 views
import React from 'react';1import { FormikErrors, FormikTouched } from 'formik';2import tw from 'twin.macro';3import { capitalize } from '@/lib/strings';45interface Props {6errors: FormikErrors<any>;7touched: FormikTouched<any>;8name: string;9children?: string | number | null | undefined;10}1112const InputError = ({ errors, touched, name, children }: Props) =>13touched[name] && errors[name] ? (14<p css={tw`text-xs text-red-400 pt-2`}>15{typeof errors[name] === 'string'16? capitalize(errors[name] as string)17: capitalize((errors[name] as unknown as string[])[0])}18</p>19) : (20<>{children ? <p css={tw`text-xs text-neutral-400 pt-2`}>{children}</p> : null}</>21);2223export default InputError;242526