import { ThoughtOfTheDay } from "impaktapps-design";
import { useContext } from "react";
import { inputProps } from "../interface/inputfieldProps";
import { DataContext } from "../context/Context";
import { withJsonFormsControlProps } from "@jsonforms/react";
import { getFieldName } from "../permissions/getFieldName";
import ComponentWrapper from "../common/ComponentWrapper";
import { getComponentProps } from "../common/getComponentProps";

const Thought = ({
  data,
  uischema,
  path,
  schema,
  rootSchema
}: inputProps) => {
  const { pageName, permissions, theme } = useContext(DataContext);
  const fieldName = getFieldName(path);
  return (
    <ComponentWrapper
    {...getComponentProps(`${pageName}:${fieldName}`,permissions,schema,rootSchema)}>
      <ThoughtOfTheDay
        data={data}
        uischema={uischema}
        theme={theme}
      />
    </ComponentWrapper>
  );
};

export default withJsonFormsControlProps(Thought);
