2023-09-03 02:52:41 +08:00
|
|
|
import { Button, Form, Input, Typography } from 'antd';
|
2023-09-01 00:11:47 +08:00
|
|
|
import React from 'react';
|
2023-09-03 02:52:41 +08:00
|
|
|
import { useEvent } from '../hooks/useEvent';
|
|
|
|
import axios from 'axios';
|
2023-09-01 00:11:47 +08:00
|
|
|
|
|
|
|
export const Login: React.FC = React.memo(() => {
|
2023-09-03 02:52:41 +08:00
|
|
|
const handleLogin = useEvent(async (values: any) => {
|
|
|
|
await axios.post('/api/user/login', {
|
|
|
|
username: values.username,
|
|
|
|
password: values.password,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="w-full h-full flex justify-center items-center">
|
|
|
|
<div className="w-80 -translate-y-1/4">
|
|
|
|
<Typography.Title level={2}>Tianji</Typography.Title>
|
|
|
|
<Form layout="vertical" onFinish={handleLogin}>
|
|
|
|
<Form.Item
|
|
|
|
label="Username"
|
|
|
|
name="username"
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
>
|
|
|
|
<Input size="large" />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
|
|
label="Password"
|
|
|
|
name="password"
|
|
|
|
rules={[{ required: true }]}
|
|
|
|
>
|
|
|
|
<Input size="large" />
|
|
|
|
</Form.Item>
|
|
|
|
<Form.Item>
|
|
|
|
<Button type="primary" size="large" htmlType="submit" block={true}>
|
|
|
|
Login
|
|
|
|
</Button>
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-09-01 00:11:47 +08:00
|
|
|
});
|
|
|
|
Login.displayName = 'Login';
|