Skip to content

Instantly share code, notes, and snippets.

@Raja0sama
Created May 18, 2021 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raja0sama/5452c7bb304b234925e7807432205754 to your computer and use it in GitHub Desktop.
Save Raja0sama/5452c7bb304b234925e7807432205754 to your computer and use it in GitHub Desktop.
component
import React, { useState } from 'react';
import styles from './index.less';
import { Form, Input, Button, Checkbox } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons';
import { useIntl, connect, FormattedMessage } from 'umi';
import { Login as Log } from '@/models/user';
const LoginMessage = ({ content }) => (
<Alert
style={{
marginBottom: 24,
}}
message={content}
type="error"
showIcon
/>
);
const Login = (props) => {
const loading = props.loading;
const onFinish = (values) => {
props.login(values);
};
return (
<div className={styles.main}>
<Form
name="normal_login"
className="login-form"
initialValues={{
remember: true,
}}
onFinish={onFinish}
>
<Form.Item
name="username"
rules={[
{
required: true,
message: 'Please input your Username!',
},
]}
>
<Input prefix={<UserOutlined className="site-form-item-icon" />} placeholder="Username" />
</Form.Item>
<Form.Item
name="password"
rules={[
{
required: true,
message: 'Please input your Password!',
},
]}
>
<Input
prefix={<LockOutlined className="site-form-item-icon" />}
type="password"
placeholder="Password"
/>
</Form.Item>
<Form.Item >
<Button
loading={loading}
block
type="primary"
htmlType="submit"
className="login-form-button"
>
Login
</Button>
</Form.Item>
</Form>
<div className={styles.btnsContainer}>
<a href="/user/register" className={styles.btn}>
<Button
block
htmlType="submit"
>
Signup
</Button>
</a>
<a href="/user/resetPassword">
<Button type="link" className={styles.forgetBtn}>
Forget Password?
</Button>
</a>
</div>
</div>
);
};
export default connect(
({ user, loading }) => ({
loading: user.loading.login,
}),
{ login: Log },
)(Login);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment