'use strict'; import React, { useEffect, useRef } from 'react'; import { connect } from 'react-redux'; import { push } from 'react-router-redux'; import { Form, Button, Toast } from '@douyinfe/semi-ui'; import { login, LOGIN_SUCCESS } from '../actions/auth'; import { IconLock, IconUser } from '@douyinfe/semi-icons'; import '../style.less' const Login = props => { const { dispatch, user, error, actions, apiRoot, isRequesting } = props const form = useRef(); useEffect(() => { if (error) { Toast.error(error); form.current.setValue('password', '') } }, [error]) useEffect(() => { if (user && user.authorized) { dispatch(push('/console')); localStorage.setItem('poms_open_sider', JSON.stringify([])) localStorage.removeItem('poms_selected_sider') } }, [user]) return (
); } function mapStateToProps (state) { const { auth, global } = state; return { user: auth.user, error: auth.error, actions: global.actions, apiRoot: global.apiRoot, isRequesting: auth.isRequesting } } export default connect(mapStateToProps)(Login);