import React, {Component} from 'react'; import Link from '../base/Link'; import Modal from '../base/Modal'; import ModalBody from '../base/ModalBody'; import ModalHeader from '../base/ModalHeader'; import ModalFooter from '../base/ModalFooter'; import * as session from '../../../backend/sync/session'; import {showModal} from './index'; import SignupModal from './SignupModal'; import * as sync from '../../../backend/sync'; import {trackEvent} from '../../../backend/ganalytics'; class LoginModal extends Component { constructor (props) { super(props); this.state = { step: 1, loading: false, error: '', title: '', message: '', } } async _handleLogin (e) { e.preventDefault(); this.setState({error: '', loading: true}); const email = this._emailInput.value; const password = this._passwordInput.value; try { await session.login(email, password); // Clear all existing sync data that might be there and enable sync await sync.resetLocalData(); sync.doInitialSync(); this.setState({step: 2, loading: false}); } catch (e) { this.setState({error: e.message, loading: false}); } } _handleSignup (e) { e.preventDefault(); this.modal.hide(); showModal(SignupModal); trackEvent('Auth', 'Switch', 'To Signup'); } show ({title, message}) { this.setState({step: 1, error: '', title, message}); this.modal.show(); setTimeout(() => this._emailInput.focus(), 100); } render () { const {step, title, message} = this.state; if (step === 1) { return ( this.modal = m} {...this.props}> {title || "Login to Your Account"} {message ? ( {message} ) : null} Email this._emailInput = n}/> Password this._passwordInput = n}/> {this.state.error ? ( ** {this.state.error} ) : null} Don't have an account yet? {" "} Signup {this.state.loading ? : null} Login ) } else { return ( this.modal = m} {...this.props}> Login Success Enjoy your stay! If you have any questions or concerns, send you email to {" "} support@insomnia.rest this.modal.hide()}> Close ) } } } LoginModal.propTypes = {}; export default LoginModal;
{message}
If you have any questions or concerns, send you email to {" "} support@insomnia.rest