/* eslint-disable */
import { Checkbox } from 'antd';
import React from 'react';
import { useIntl } from '@wisdom-utils/components';
import LoginForm from '../../components/Login';
import { Form } from 'antd';
import LoginMessage from '../../js/loginMessage';
import LoginContext from '../../components/Login/LoginContext';
import styles from './index.less';
const { UserName, Password, Submit } = LoginForm;
const FormLogin = props => (
  <div className={styles.form_login}>
    <LoginContext.Provider>
      <Form
        form={props.form}
        onFinish={values => {
          if (props.onSubmit) {
            props.onSubmit(values);
          }
        }}
      >
        {props.status === 'error' && props.type === 'account' && !props.submitting && (
          <LoginMessage
            content={useIntl().formatMessage({
              id: 'pages.login.accountLogin.errorMessage',
            })}
          />
        )}
        <UserName
          name="userName"
          placeholder={useIntl().formatMessage({
            id: 'pages.login.username.placeholder',
          })}
          rules={[
            {
              required: true,
              message: useIntl().formatMessage({
                id: 'pages.login.username.required',
              }),
            },
          ]}
        />
        <Password
          name="password"
          placeholder={useIntl().formatMessage({
            id: 'pages.login.password.placeholder',
          })}
          rules={[
            {
              required: true,
              message: useIntl().formatMessage({
                id: 'pages.login.password.required',
              }),
            },
          ]}
        />
        <div className={styles.checkbox_wrap}>
          <Checkbox checked={props.autoLogin} onChange={e => props.setAutoLogin(e.target.checked)}>
            {'记住密码'}
          </Checkbox>
          <a href="#">忘记密码?</a>
        </div>
        <Submit loading={props.submitting}>{useIntl().formatMessage({ id: 'pages.login.submit' })}</Submit>
      </Form>
    </LoginContext.Provider>
  </div>
);

export default FormLogin;
