import React from "react";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
import DocumentsUploadComponent from "./documents-upload.component";
import { handleUpload } from "./documents-upload.utility";

const mapStateToProps = createStructuredSelector({
  currentUser: selectCurrentUser,
  bodyshop: selectBodyshop,
});

export function DocumentsUploadContainer({
  jobId,
  tagsArray,
  invoiceId,
  currentUser,
  bodyshop,
  callbackAfterUpload,
  onChange,
}) {
  return (
    <DocumentsUploadComponent
      handleUpload={(ev) =>
        handleUpload(ev, {
          bodyshop: bodyshop,
          uploaded_by: currentUser.email,
          jobId: jobId,
          invoiceId: invoiceId,
          tagsArray: tagsArray,
          callback: callbackAfterUpload,
        })
      }
    />
  );
}

export default connect(mapStateToProps, null)(DocumentsUploadContainer);
