import { FormLabel, FormControl, FormHelperText } from "@chakra-ui/react"; import React from "react"; export interface IFormControlWithErrorProps { children: React.ReactNode; errors: any; id: string; help?: string; label?: string; } export function FormControlWithError({ id, label, help, children, errors, ...rest }: IFormControlWithErrorProps) { return ( {label && {label}} {children} {(errors[id] || help) && ( {errors[id]?.message || help} )} ); }