import React from "react";
import { useTranslation } from "react-i18next";
import { Namespaces } from "../../../../i18n/i18n";
import { InputType } from "../../../../components/common/Input";
import {
  renderInput,
  renderError,
} from "../../../../components/common/formHelpers";
import { CreateWorkflowTemplateVersion } from "../services/WorkflowTemplateService";

interface GeneralTabProps {
  data: CreateWorkflowTemplateVersion;
  errors: Record<string, string>;
  isEditMode: boolean;
  onFieldChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

const GeneralTab: React.FC<GeneralTabProps> = ({
  data,
  errors,
  onFieldChange,
}) => {
  const { t } = useTranslation<typeof Namespaces.Common>();

  return (
    <div>
      {renderError("_general", errors)}

      {renderInput(
        "name",
        t("WorkflowTemplateName"),
        data,
        errors,
        InputType.text,
        false,
        "",
        "",
        0,
        true,
        undefined,
        onFieldChange,
      )}

      {renderInput(
        "activityNameTemplate",
        t("ActivityNameTemplate"),
        data,
        errors,
        InputType.text,
        false,
        "",
        "",
        0,
        true,
        undefined,
        onFieldChange,
      )}
      {renderInput(
        "description",
        t("Description"),
        data,
        errors,
        InputType.textarea,
        false,
        "",
        "",
        0,
        true,
        undefined,
        onFieldChange,
      )}
    </div>
  );
};

export default GeneralTab;
