import * as React from 'react'; import { RouteComponentProps } from 'react-router'; import { connect } from 'react-redux'; import { pushFlashMessage, clearAllFlashMessages } from '@/redux/actions/flash'; import NetworkErrorMessage from '@/components/NetworkErrorMessage'; type State = Readonly<{ isLoading: boolean; errorMessage?: string; code: string; }>; class LoginCheckpointContainer extends React.PureComponent { state: State = { code: '', isLoading: false, }; moveToNextInput (e: React.KeyboardEvent, isBackspace: boolean = false) { const form = e.currentTarget.form; if (form) { const index = Array.prototype.indexOf.call(form, e.currentTarget); const element = form.elements[index + (isBackspace ? -1 : 1)]; // @ts-ignore element && element.focus(); } } handleNumberInput = (e: React.KeyboardEvent) => { const number = Number(e.key); if (isNaN(number)) { return; } this.setState(s => ({ code: s.code + number.toString() })); this.moveToNextInput(e); }; handleBackspace = (e: React.KeyboardEvent) => { const isBackspace = e.key === 'Delete' || e.key === 'Backspace'; if (!isBackspace || e.currentTarget.value.length > 0) { e.currentTarget.value = ''; return; } this.setState(s => ({ code: s.code.substring(0, s.code.length - 2) })); e.currentTarget.value = ''; this.moveToNextInput(e, true); }; render () { return (

Device Checkpoint

null}>

This account is protected with two-factor authentication. Please provide an authentication code from your device in order to continue.

{ [1, 2, 3, 4, 5, 6].map((_, index) => ( )) }
); } } const mapDispatchToProps = { pushFlashMessage, clearAllFlashMessages, }; export default connect(null, mapDispatchToProps)(LoginCheckpointContainer);