import { LockOutlined, UserOutlined } from '@ant-design/icons'; import { Button, Form, Input, Typography } from 'antd'; import axios from 'axios'; // import { dispatchBox, dispatchToken } from 'features/Login/loginSlice'; import React, { useState } from 'react'; // import { useDispatch } from 'react-redux'; // import { useHistory } from "react-router-dom"; import { HOST } from '../../config/index'; const { Text } = Typography; const Login = () => { const [error, setError] = useState(''); const [loading, setLoading] = useState(false); // const dispatch = useDispatch(); // let history = useHistory(); const onFinish = async (values) => { setLoading(true); const dataReq = { email: values.email, password: values.password, } await axios({ method: 'POST', url: `${HOST}/api/login`, headers: {}, data: dataReq }).then((res) => { if (res.data.status === 10000) { // dispatch(dispatchToken({ token: 'Bearer ' + res.data.access_token })); // dispatch(dispatchBox({ rule: res.data.user_info.rule })) setError(''); localStorage.setItem('refresh_token', 'Bearer ' + res.data.refresh_token); localStorage.setItem('access_token', 'Bearer ' + res.data.access_token); localStorage.setItem('rule', res.data.user_info.rule); // history.push('/preferential-management') } else { setError('Sai tài khoản hoặc mật khẩu'); } }) .catch(err => { setError('Vui lòng kiểm tra lại đường truyền mạng') console.error(err); }) setLoading(false); }; const onFinishFailed = (errorInfo) => { console.log('Failed:', errorInfo); }; return (