'use strict';

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

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

var _presenter2 = _interopRequireDefault(_presenter);

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

var _modifications = require('../../../../../../common/actions/modifications');

var _quizEntries = require('../../../../../api/quizEntries');

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

function mapStateToProps(state, props) {
  var workingQuizEntry = props.quizEntry.getWorkingInstance();
  var properties = workingQuizEntry.properties;
  var sampleNum = properties.get('sampleNum');
  var selection = sampleNum > 0 ? 'rand' : 'all';

  return {
    workingBank: workingQuizEntry.getEntry(),
    workingQuizEntry: workingQuizEntry,
    questionSelection: properties.get('selection', selection),
    sampleNum: sampleNum,
    pointsPossible: workingQuizEntry.pointsPossible.toString()
  };
}

exports.default = (0, _reactRedux.connect)(mapStateToProps, {
  changeQuizEntryPoints: _modifications.changeQuizEntryPoints,
  changeQuizEntryProperties: _modifications.changeQuizEntryProperties,
  changeQuizEntryEntry: _modifications.changeQuizEntryEntry,
  clearModifications: _modifications.clearModifications,
  updateQuizEntry: _quizEntries.updateQuizEntry
})(_presenter2.default);