<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import fileSizeDisplay from 'lib/fileSizeDisplay';

import FineUploaderTraditional from 'fine-uploader-wrappers';
import Gallery from 'react-fine-uploader';

// Presentationals:
import NeedSigninWarning from 'presentationals/objects/NeedSigninWarning';

// Helpers:
import IfAuthHOC from '../../../../lib/IfAuthHOC';

function ImportDeckForm({ authState, deckImportState }) {
  const uploader = new FineUploaderTraditional({
    options: {
      chunking: {
        enabled: false,
      },
      deleteFile: {
        enabled: false,
      },
      request: {
        endpoint: '/conversions',
      },
      retry: {
        enableAuto: false,
      },
    },
  });

  return (
    <IfAuthHOC
      isAuthenticated={authState}
      fallback={() => <NeedSigninWarning requestedAction="import a deck" />}
    >
      <Gallery uploader={uploader} />
    </IfAuthHOC>
  );
}

ImportDeckForm.propTypes = {
  authState: PropTypes.shape({
    id: PropTypes.string,
  }),
  deckImportState: PropTypes.shape({
    selectedFile: PropTypes.object,
    uploadStarted: PropTypes.bool,
    uploadPercent: PropTypes.number,
    uploadErrorMessage: PropTypes.string,
    uploadSucceeded: PropTypes.bool,
    importStarted: PropTypes.bool,
    importSucceeded: PropTypes.bool,
    importError: PropTypes.string,
  }),
  selectUploadFile: PropTypes.func.isRequired,
};

ImportDeckForm.defaultProps = {
  authState: null,
};

export default ImportDeckForm;
<commit_msg>Working version of the uploader<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import fileSizeDisplay from 'lib/fileSizeDisplay';

import FineUploaderTraditional from 'fine-uploader-wrappers';
import Gallery from 'react-fine-uploader';
import { getAuthToken } from 'api/helpers/apiHelper';

// Presentationals:
import NeedSigninWarning from 'presentationals/objects/NeedSigninWarning';

// Helpers:
import IfAuthHOC from '../../../../lib/IfAuthHOC';

function ImportDeckForm({ authState, deckImportState }) {
  const uploader = new FineUploaderTraditional({
    options: {
      chunking: {
        enabled: false,
      },
      deleteFile: {
        enabled: false,
      },
      request: {
        endpoint: 'http://localhost:3000/api/conversions',
        customHeaders: {
          Authorization: `Bearer ${getAuthToken()}`,
        },
      },
      validation: {
        allowedExtensions: ['pptx', 'pdf'],
        itemLimit: 1,
        sizeLimit: 512000000, // 500mb
      },
      retry: {
        enableAuto: false,
      },
    },
  });

  return (
    <IfAuthHOC
      isAuthenticated={authState}
      fallback={() => <NeedSigninWarning requestedAction="see your imports" />}
    >
      <Gallery uploader={uploader} />
    </IfAuthHOC>
  );
}

ImportDeckForm.propTypes = {
  authState: PropTypes.shape({
    id: PropTypes.string,
  }),
  deckImportState: PropTypes.shape({
    selectedFile: PropTypes.object,
    uploadStarted: PropTypes.bool,
    uploadPercent: PropTypes.number,
    uploadErrorMessage: PropTypes.string,
    uploadSucceeded: PropTypes.bool,
    importStarted: PropTypes.bool,
    importSucceeded: PropTypes.bool,
    importError: PropTypes.string,
  }),
  selectUploadFile: PropTypes.func.isRequired,
};

ImportDeckForm.defaultProps = {
  authState: null,
};

export default ImportDeckForm;

{'fraction_non_alphanumeric': 0.12112259970457903, 'fraction_numerical': 0.005022156573116691, 'mean_word_length': 3.243107769423559, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1566633', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1028, 'n_words': 207}