import React from 'react';
import { Button, Input } from 'antd';
import { connect, DispatchProp } from 'dva';
import { formatMessage } from 'umi-plugin-locale';
import { CheckModelState } from './model';

const RegisterPage: React.FC<DispatchProp & CheckModelState> = ({
  password,
  submitting,
  dispatch,
}) => {
  return (
    <>
      <Input
        className="item"
        placeholder={formatMessage({ id: 'common.pwdHolder' })}
        value={password}
        onChange={e => dispatch({ type: 'check/onUpdatePassword', payload: e.target.value })}
        size="large"
        type="password"
      />

      <Button
        className="item gradient"
        type="primary"
        loading={submitting}
        onClick={() => dispatch({ type: 'check/submitRegister' })}
        size="large"
      >{formatMessage({ id: 'check.register' })}</Button>
    </>
  );
}

export default connect(
  ({ check } : any) => ({ ...check })
)(RegisterPage) as any;
