import React, { Component } from 'react' import { connect } from 'dva'; import { Form, Icon as LegacyIcon } from '@ant-design/compatible'; import { Button, Input, Drawer } from 'antd'; import * as ycore from 'ycore' import styles from './index.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, } } // 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!' ycore.yconsole.log(prefix, message) } if (EncUsername && EncPassword){ this.setState({ ShowLoading: true, StateMessage: 'Wait a sec...' }); if (ycore.AppSettings.InfiniteLogin == true) { ycore.yconsole.log(prefix, 'InfiniteLogin is enabled! Disabled getAuth') } else { ycore.yconsole.log(prefix, 'Initialising login process...') ycore.__AppSetup__(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 }) } if (response == '404') { this.setState({ StateIcon: 'exclamation-circle', StateMessage: 'Invalid Data', StateException: true }) } if (response == '500') { this.setState({ StateIcon: 'cluster', StateMessage: 'Server Error', StateException: true }) } } render() { const { visible } = this.props const { getFieldDecorator } = this.props.form; const { ShowLoading, StateIcon, StateMessage, StateException } = this.state; return (