Merge branch 'develop' of https://gitlab.com/empatnusabangsa/ppob/ppob-frontend into develop
This commit is contained in:
commit
2165c7a535
|
@ -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 (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user