import { h, Component } from 'preact'; // import PropTypes from 'prop-types'; import { BrowserRouter, Route, Switch, Redirect, withRouter } from 'react-router-dom' import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import * as authActions from './auth.actions'; import Login from './login.component'; import Logout from './logout.component'; import Signup from './signup.component'; import { randint } from '../util/math' class AuthRouter extends Component { render(){ console.log(this.props, Login) return (
) } componentDidMount(){ document.querySelector('.diamond').style.backgroundImage = 'linear-gradient(' + (randint(40)-5) + 'deg, #fde, #ffe)' } } class AuthGate extends Component { render(){ console.log(this.props.auth) if (!this.props.auth.initialized) { return
Loading
} if (this.props.auth.isAuthenticated) return
{this.props.children}
return } componentDidMount(){ this.props.actions.checkin() } } const mapStateToProps = (state) => ({ auth: state.auth }); const mapDispatchToProps = (dispatch) => ({ actions: bindActionCreators(authActions, dispatch) }); export default connect(mapStateToProps, mapDispatchToProps)(AuthGate); // { // console.log(window.location.pathname) // this.props.actions.setReturnTo(window.location.pathname) // return ( // // ) // }} />