import { useState, useEffect } from "react";
import withHelperText from "../../../../hoc/withHelperText";
import AccordianItem, { AccordianItemProps } from "./AccordianItem";

const AccordianItemContainer = (props: AccordianItemProps) => {
  const [accordianItemProps, setAccordianItemProps] = useState<AccordianItemProps>(
    {} as AccordianItemProps
  );
  const [toggle, setToggle] = useState(true);
  useEffect(() => {
    const accordianItemsProps = { ...props };
    setAccordianItemProps(accordianItemsProps);
  }, [props]);
  return (
    <AccordianItem
      {...accordianItemProps}
      expanded={toggle}
      onToggle={setToggle}
    />
  );
};
export default withHelperText(AccordianItemContainer);
