import React from "react";
import {
FormLabel,
FormControl,
FormHelperText,
FormErrorMessage,
Icon,
} from "@chakra-ui/react";
import { RiErrorWarningFill } from "react-icons/ri";
export interface IFormControlWithErrorProps {
children: React.ReactNode;
errors: any;
id: string;
help?: string;
label?: string;
}
export function FormControlWithError({
id,
label,
help = "",
children,
errors,
...rest
}: IFormControlWithErrorProps) {
const helpTextColor = { color: "black", _dark: { color: "gray.400" } };
return (
{label && {label}}
{children}
{!errors[id]?.message ? (
{help}
) : (
{errors[id].message}
)}
);
}