"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.mapDispatchToProps = exports.mapStateToProps = void 0;

var _redux = require("redux");

var _reactRedux = require("../../../common/react-redux");

var _qtiImports = require("../../../common/actions/qtiImports");

var _qtiImports2 = require("../../api/qtiImports");

var _constants = require("@instructure/quiz-common/lib/constants");

var _ImportModal = _interopRequireWildcard(require("../../../common/components/ImportModal"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/lib/format-message"));

var callsToCheck = [_constants.CREATE_QTI_IMPORT, _constants.FILE_UPLOAD_CALL, _constants.FILE_UPLOAD_URL_CALL]; // Consuming Components must pass in qtiImportRecord, parentType, and parentId

var mapStateToProps = function mapStateToProps(state, props) {
  var qtiImportRecord = props.qtiImport;
  var pv = (0, _ImportModal.progressValue)(qtiImportRecord.progressNumber(), state.get('calls'), callsToCheck);
  return {
    failureMessage: qtiImportRecord.message || '',
    importMessage: "Fichiers QTI 1.2 et 2.x (.zip) uniquement",
    progressValue: pv,
    acceptFileType: '.zip',
    importModalId: 'qtiImport'
  };
};

exports.mapStateToProps = mapStateToProps;

var mapDispatchToProps = function mapDispatchToProps(dispatch, props) {
  var boundQtiFileUpload = (0, _redux.bindActionCreators)(_qtiImports2.qtiFileUpload, dispatch);
  return {
    onContinue: (0, _redux.bindActionCreators)(_qtiImports.clearQtiImports, dispatch),
    fileUpload: function fileUpload(file, cancelAction) {
      boundQtiFileUpload(file, props.parentId, props.parentType, cancelAction);
    }
  };
};

exports.mapDispatchToProps = mapDispatchToProps;

var _default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_ImportModal.default);

exports.default = _default;