'use strict';

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

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

var _taking = require('../../../../../common/actions/taking');

var _alerts = require('../../../../../common/actions/alerts');

var _presenter = require('./presenter');

var _presenter2 = _interopRequireDefault(_presenter);

var _QuizSession = require('../../../../../common/records/QuizSession');

var _QuizSession2 = _interopRequireDefault(_QuizSession);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function mapStateToProps(state, ownProps) {
  var quizSessionId = ownProps.quizSessionId;
  var quizSession = _QuizSession2.default.create(state.getIn(['quizSessions', quizSessionId]));
  var allowBacktracking = quizSession.get('allowBacktracking');
  var isOneQuestionAtATime = quizSession.isOneQuestionAtATime();
  var shouldRenderPrevious = allowBacktracking && ownProps.currentSessionItemPosition > 1;

  return {
    isOneQuestionAtATime: isOneQuestionAtATime,
    shouldRenderPrevious: shouldRenderPrevious
  };
}

var mapDispatchToProps = exports.mapDispatchToProps = {
  previousQuestion: _taking.previousQuestion,
  screenreaderNotification: _alerts.screenreaderNotification
};

exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_presenter2.default);