import { AntInput, FieldType } from "components/Form/FormItem";
import { Field, Form, FormikProps } from "formik";
import React from "react";
import { addingHttpsPrefix } from "../../../../utils/string";
import { BandsintownEditorModalFormValues } from "../../BandsintownEditorModal";

interface ProductEditorFormProps {
  actions?: JSX.Element;
}

const ProductEditorForm: React.FC<
  FormikProps<BandsintownEditorModalFormValues> & ProductEditorFormProps
> = ({ handleSubmit, actions }) => {
  return (
    <React.Fragment>
      <Form className="link-editor-form" onSubmit={handleSubmit}>
        <Field
          component={AntInput}
          name="url"
          type={FieldType.input}
          labelClassName="opacity--80 font__weight--medium"
          label="Bandsintown URL"
          placeholder="https://www.bandsintown.com/"
          beforeSetValue={addingHttpsPrefix}
        />
        {actions}
      </Form>
    </React.Fragment>
  );
};

export default ProductEditorForm;
