import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { initSequence, shouldRedirectTo, startAsUser, fetchExercises } from "../../store/rehab/main";
import "./style.css";

var ResultRecordScreen = function ResultRecordScreen(props) {
  var dispatch = useDispatch();

  var _useSelector = useSelector(function (state) {
    return state.rehab.main;
  }),
      users = _useSelector.users;

  var handleReturnAdmin = function handleReturnAdmin(e) {
    dispatch(shouldRedirectTo());
  };

  var handleRecordNew = function handleRecordNew(e) {
    dispatch(initSequence());
  };

  var handleStartSession = function handleStartSession() {
    dispatch(startAsUser());
    dispatch(fetchExercises(users[0]));
  };

  var validateStartSession = function validateStartSession() {
    return users.length === 1 ? true : false;
  };

  return /*#__PURE__*/React.createElement("div", {
    className: "result-record"
  }, /*#__PURE__*/React.createElement("div", {
    className: "container"
  }, /*#__PURE__*/React.createElement("h2", {
    className: "splash-subtitle"
  }, "What would you like to do?"), /*#__PURE__*/React.createElement("div", {
    className: "splash-actions"
  }, /*#__PURE__*/React.createElement("button", {
    className: "btn-outline",
    onClick: handleReturnAdmin
  }, "Return to Admin Console"), /*#__PURE__*/React.createElement("button", {
    className: "btn-outline",
    onClick: handleRecordNew
  }, "Record Another Exercise")), /*#__PURE__*/React.createElement("div", null, validateStartSession() && /*#__PURE__*/React.createElement("button", {
    className: "btn-outline",
    onClick: handleStartSession
  }, "Start Session"))));
};

export default ResultRecordScreen;