Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

1.5 KB
Raw Blame
import { Plus } from "lucide-react";
import PropTypes from "prop-types";
import { deploymentsStaticContent } from "../../../helpers/GetStaticData";
import usePostHogEvents from "../../../hooks/usePostHogEvents";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";
import { CustomButton } from "../../widgets/custom-button/CustomButton";

function Header({ type, openAddModal, enableSearch, onSearch, setSearchList }) {
  const { posthogDeploymentEventText, setPostHogCustomEvent } =
    usePostHogEvents();

  const handleOnClick = () => {
    openAddModal(false);

    try {
      setPostHogCustomEvent(posthogDeploymentEventText[type], {
        info: `Clicked on '+ ${deploymentsStaticContent[type].addBtn}' button`,
      });
    } catch (_err) {
      // If an error occurs while setting custom posthog event, ignore it and continue
    }
  };

  const addButton = (
    <CustomButton
      type="primary"
      icon={<Plus />}
      data-testid={`${type}-deployment-add-btn`}
      onClick={handleOnClick}
    >
      {deploymentsStaticContent[type].addBtn}
    </CustomButton>
  );

  return (
    <ToolNavBar
      title={deploymentsStaticContent[type].title}
      customButtons={addButton}
      enableSearch={enableSearch}
      onSearch={onSearch}
      setSearchList={setSearchList}
    />
  );
}

Header.propTypes = {
  type: PropTypes.string.isRequired,
  openAddModal: PropTypes.func.isRequired,
  enableSearch: PropTypes.bool,
  onSearch: PropTypes.func,
  setSearchList: PropTypes.func,
};

export { Header };