const { connect } = require('preact-redux');

const Login = require('./login.component');

const addState = connect(
    (state) => {
        const { ws } = state;
        function submitLogin(name, password) {
            return ws.sendAccountLogin(name, password);
        }
        function submitRegister(name, password) {
            return ws.sendAccountCreate(name, password);
        }
        function submitDemo() {
            return ws.sendAccountDemo();
        }
        return { account: state.account, submitLogin, submitRegister, submitDemo };
    },
);

module.exports = addState(Login);
