import React, { Component } from 'react' import {GetAuth, InitSDCP, DevOptions, asyncSDCP} from 'ycore'; import PropTypes from 'prop-types'; import { connect } from 'dva'; import { Button, Form, Input, Drawer, Icon, Collapse } from 'antd' import styles from './index.less'; import formstyle from './formstyle.less' const FormItem = Form.Item @connect(({ loading }) => ({ loading })) @Form.create() class YulioID extends Component { constructor(props) { super(props) this.state = { // Drawers Visibility (Default on False) MainLoginVisible: true, ShowLoading: false, Answered: false, } this.handleRetry = this.handleRetry.bind(this); } // Handlers & others handleUsername(text) { this.setState({ RawUsername: text.target.value }); } handlePassword(text) { this.setState({ RawPassword: text.target.value }); } handleRetry() { this.setState({ShowLoading: false, StateException: false, StateIcon: ''}) } handleEnter = (e) => { this.handleLogin(); } handleLogin = () => { var prefix = '[YID]: '; const { RawUsername, RawPassword } = this.state; var EncPassword = btoa(RawPassword); var EncUsername = btoa(RawUsername); if (!EncUsername || !EncPassword) { var message = 'Incomplete information!' console.log(prefix, message) } if (EncUsername && EncPassword){ this.setState({ ShowLoading: true, StateMessage: 'Wait a sec...' }); if (DevOptions.InfiniteLogin == true) { console.log(prefix, 'InfiniteLogin is enabled! Disabled getAuth') } else { console.log(prefix, 'Initialising login process...') GetAuth(EncUsername, EncPassword, (exception, response) => this.handleResponse(response)) } } } handleResponse = (response) => { if (response == '200') { this.setState({ StateIcon: 'login', StateMessage: 'Wait a sec...', StateException: false }) } if (response == '400') { this.setState({ StateIcon: 'exclamation-circle', StateMessage: 'Invalid credentials', StateException: true }) } } render() { const { visible } = this.props const { getFieldDecorator } = this.props.form; const { ShowLoading, StateIcon, StateMessage, StateException } = this.state; const { Panel } = Collapse; return (