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

interface ProductEditorFormProps {
  actions?: JSX.Element;
}

const ProductEditorForm: React.FC<
  FormikProps<ShopMyShelfEditorModalFormValues> & 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="Shop My collection link"
          placeholder="https://shopmy.us/collections/"
          beforeSetValue={addingHttpsPrefix}
        />
        {actions}
      </Form>
    </React.Fragment>
  );
};

export default ProductEditorForm;
