import { HelperText } from "../Widgets/DomainProps";

export interface HelperTextProps {
  helperText?: Partial<HelperText>;
  className?: string;
  [key: string]: any;
}

const withHelperText = (Component: React.ComponentType<any>) => {
  return (props: HelperTextProps) => {
    const helperTextProps: HelperText = { ...props.helperText } as HelperText;

    return helperTextProps.isApply ? (
      <div>
        <Component {...props} />
        <div
          id={helperTextProps.widgetStyle?.id ?? ""}
          className={`${helperTextProps.widgetStyle?.className ?? ""}`}
          style={helperTextProps.widgetStyle?.inline ?? {}}
          dangerouslySetInnerHTML={{ __html: helperTextProps.title ?? "" }}
        ></div>
      </div>
    ) : (
      <Component {...props} />
    );
  };
};

export default withHelperText;
