import React from 'react'; import classNames from 'classnames'; import { SessionIcon } from './icon'; import { withTheme } from 'styled-components'; import autoBind from 'auto-bind'; import { SessionButton, SessionButtonColor, SessionButtonType } from './basic/SessionButton'; import { Constants } from '../session'; import { SessionSpinner } from './basic/SessionSpinner'; interface State { error: string; errorCount: number; clearDataView: boolean; loading: boolean; } export const MAX_LOGIN_TRIES = 3; class SessionPasswordPromptInner extends React.PureComponent<{}, State> { private inputRef?: any; constructor(props: any) { super(props); this.state = { error: '', errorCount: 0, clearDataView: false, loading: false, }; autoBind(this); } public componentDidMount() { setTimeout(() => { this.inputRef?.focus(); }, 100); } public render() { const showResetElements = this.state.errorCount >= MAX_LOGIN_TRIES; const wrapperClass = this.state.clearDataView ? 'clear-data-wrapper' : 'password-prompt-wrapper'; const containerClass = this.state.clearDataView ? 'clear-data-container' : 'password-prompt-container'; const infoAreaClass = this.state.clearDataView ? 'warning-info-area' : 'password-info-area'; const infoTitle = this.state.clearDataView ? window.i18n('clearAllData') : window.i18n('passwordViewTitle'); const buttonGroup = this.state.clearDataView ? this.renderClearDataViewButtons() : this.renderPasswordViewButtons(); const featureElement = this.state.clearDataView ? (
{window.i18n('deleteAccountWarning')}
) : ( { this.inputRef = input; }} /> ); const infoIcon = this.state.clearDataView ? (