This commit is contained in:
ajat91.sudrajat 2021-12-21 11:44:27 +07:00
commit 2165c7a535

View File

@ -1,34 +1,29 @@
import React, {useContext} from "react"; import React from "react";
import {observer} from 'mobx-react-lite'; import {observer} from 'mobx-react-lite';
import {useStore} from "../../utils/useStore"; import {useStore} from "../../utils/useStore";
import {Button, Card, Col, Form, Input, message, Row, Typography} from 'antd'; import {Button, Card, Col, Form, Input, message, Row, Typography} from 'antd';
import {useHistory} from "react-router-dom"; import {useHistory} from "react-router-dom";
import {LINKS} from "../../routes/app"; import {LINKS} from "../../routes/app";
import {ModalLoaderContext} from "../../utils/modal";
export const Login = observer(() => { export const Login = observer(() => {
const store = useStore(); const store = useStore();
let history = useHistory(); let history = useHistory();
const [form] = Form.useForm(); const [form] = Form.useForm();
const modalLoader = useContext(ModalLoaderContext);
const handleLogin = async (params) => { const handleLogin = async (params) => {
try { try {
//modalLoader.setLoading(true);
await store.authentication.login({ await store.authentication.login({
username: params.username, username: params.username,
password: params.password, password: params.password,
}); });
//modalLoader.setLoading(false);
history.push(LINKS.HOME);
} catch (e) { } catch (e) {
modalLoader.setLoading(true);
if (e.response?.body?.message) { if (e.response?.body?.message) {
message.error(e.response.body.message); message.error(e.response.body.message);
return; return;
} }
message.error(e.message); message.error(e.message);
} }
history.push(LINKS.HOME);
} }
return ( return (