You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			90 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			90 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			TypeScript
		
	
| 
											5 years ago
										 | import classNames from 'classnames'; | ||
|  | import React from 'react'; | ||
| 
											4 years ago
										 | import { SessionInput } from '../basic/SessionInput'; | ||
| 
											4 years ago
										 | import { MAX_USERNAME_LENGTH } from './RegistrationStages'; | ||
| 
											5 years ago
										 | 
 | ||
|  | const DisplayNameInput = (props: { | ||
|  |   stealAutoFocus?: boolean; | ||
|  |   displayName: string; | ||
|  |   onDisplayNameChanged: (val: string) => any; | ||
|  |   handlePressEnter: () => any; | ||
|  | }) => { | ||
|  |   return ( | ||
|  |     // tslint:disable-next-line: use-simple-attributes
 | ||
|  |     <SessionInput | ||
|  |       autoFocus={props.stealAutoFocus || false} | ||
|  |       label={window.i18n('displayName')} | ||
|  |       type="text" | ||
|  |       placeholder={window.i18n('enterDisplayName')} | ||
|  |       value={props.displayName} | ||
|  |       maxLength={MAX_USERNAME_LENGTH} | ||
|  |       onValueChanged={props.onDisplayNameChanged} | ||
|  |       onEnterPressed={props.handlePressEnter} | ||
| 
											4 years ago
										 |       inputDataTestId="display-name-input" | ||
| 
											5 years ago
										 |     /> | ||
|  |   ); | ||
|  | }; | ||
|  | 
 | ||
|  | const RecoveryPhraseInput = (props: { | ||
|  |   recoveryPhrase: string; | ||
|  |   onSeedChanged: (val: string) => any; | ||
|  |   handlePressEnter: () => any; | ||
| 
											4 years ago
										 |   stealAutoFocus?: boolean; | ||
| 
											5 years ago
										 | }) => { | ||
|  |   return ( | ||
| 
											4 years ago
										 |     // tslint:disable-next-line: use-simple-attributes
 | ||
| 
											5 years ago
										 |     <SessionInput | ||
|  |       label={window.i18n('recoveryPhrase')} | ||
|  |       type="password" | ||
|  |       value={props.recoveryPhrase} | ||
| 
											4 years ago
										 |       autoFocus={props.stealAutoFocus || false} | ||
| 
											5 years ago
										 |       placeholder={window.i18n('enterRecoveryPhrase')} | ||
|  |       enableShowHide={true} | ||
|  |       onValueChanged={props.onSeedChanged} | ||
|  |       onEnterPressed={props.handlePressEnter} | ||
| 
											4 years ago
										 |       inputDataTestId="recovery-phrase-input" | ||
| 
											5 years ago
										 |     /> | ||
|  |   ); | ||
|  | }; | ||
|  | 
 | ||
|  | export interface Props { | ||
|  |   // tslint:disable: react-unused-props-and-state
 | ||
|  |   showDisplayNameField: boolean; | ||
|  |   showSeedField: boolean; | ||
|  |   stealAutoFocus?: boolean; | ||
| 
											5 years ago
										 |   recoveryPhrase?: string; | ||
| 
											5 years ago
										 |   displayName: string; | ||
|  |   handlePressEnter: () => any; | ||
| 
											5 years ago
										 |   onSeedChanged?: (val: string) => any; | ||
| 
											5 years ago
										 |   onDisplayNameChanged: (val: string) => any; | ||
|  | } | ||
|  | 
 | ||
|  | export const RegistrationUserDetails = (props: Props) => { | ||
| 
											5 years ago
										 |   if (props.showSeedField && (props.recoveryPhrase === undefined || !props.onSeedChanged)) { | ||
| 
											5 years ago
										 |     throw new Error('if show seed is true, we need callback + value'); | ||
|  |   } | ||
| 
											5 years ago
										 |   return ( | ||
|  |     <div className={classNames('session-registration__entry-fields')}> | ||
|  |       {props.showSeedField && ( | ||
|  |         <RecoveryPhraseInput | ||
| 
											5 years ago
										 |           recoveryPhrase={props.recoveryPhrase as string} | ||
| 
											5 years ago
										 |           handlePressEnter={props.handlePressEnter} | ||
| 
											5 years ago
										 |           onSeedChanged={props.onSeedChanged as any} | ||
| 
											4 years ago
										 |           stealAutoFocus={props.stealAutoFocus} | ||
| 
											5 years ago
										 |         /> | ||
|  |       )} | ||
|  |       <div className="inputfields"> | ||
|  |         {props.showDisplayNameField && ( | ||
| 
											4 years ago
										 |           // tslint:disable-next-line: use-simple-attributes
 | ||
| 
											5 years ago
										 |           <DisplayNameInput | ||
| 
											4 years ago
										 |             stealAutoFocus={!props.showSeedField && props.stealAutoFocus} | ||
| 
											5 years ago
										 |             displayName={props.displayName} | ||
|  |             handlePressEnter={props.handlePressEnter} | ||
|  |             onDisplayNameChanged={props.onDisplayNameChanged} | ||
|  |           /> | ||
|  |         )} | ||
|  |       </div> | ||
|  |     </div> | ||
|  |   ); | ||
|  | }; |