diff --git a/ts/components/session/RegistrationTabs.tsx b/ts/components/session/RegistrationTabs.tsx index 338693fab..8b80a4e50 100644 --- a/ts/components/session/RegistrationTabs.tsx +++ b/ts/components/session/RegistrationTabs.tsx @@ -16,9 +16,14 @@ enum SignInMode { LinkingDevice = 'LinkingDevice', } +enum SignUpMode { + Default = 'Default', + SessionIDGenerated = 'SessionIDGenerated', +} interface State { selectedTab: 'create' | 'signin'; signInMode: SignInMode; + signUpMode: SignUpMode; seed: string; displayName: string; password: string; @@ -29,8 +34,6 @@ interface TabSelectEvent { type: 'create' | 'signin'; } - - const Tab = ({ isSelected, label, @@ -44,8 +47,8 @@ const Tab = ({ }) => { const handleClick = onSelect ? () => { - onSelect({ type }); - } + onSelect({ type }); + } : undefined; return ( @@ -74,6 +77,7 @@ export class RegistrationTabs extends React.Component { this.state = { selectedTab: 'create', signInMode: SignInMode.Default, + signUpMode: SignUpMode.Default, seed: '', displayName: '', password: '', @@ -81,8 +85,6 @@ export class RegistrationTabs extends React.Component { }; } - - public render() { return this.renderTabs(); } @@ -134,22 +136,93 @@ export class RegistrationTabs extends React.Component { private renderSections() { const { selectedTab } = this.state; if (selectedTab === 'create') { - return
TODO CREATE
; + return this.renderSignUp(); } return this.renderSignIn(); } - private renderSignIn() { - const { signInMode } = this.state; + private renderSignUp() { + return ( +
+ {this.renderSignUpHeader()} + + {this.renderSignUpButton()} + {this.getRenderTermsConditionAgreement()} +
+ ); + } + + private getRenderTermsConditionAgreement() { + const { selectedTab, signInMode, signUpMode } = this.state; + if (selectedTab === 'create') { + if (signUpMode !== SignUpMode.Default) { + return this.renderTermsConditionAgreement(); + } else { + return null; + } + } else { + if (signInMode !== SignInMode.Default) { + return this.renderTermsConditionAgreement(); + } else { + return null; + } + } + } + + private renderSignUpHeader() { + return ( +
+ All users are randomly generated a set of numbers that act as their + unique Session ID. Share your Session ID in order to chat with your + friends! +
+ ); + } + + private renderSignUpButton() { + const { signUpMode } = this.state; + + let buttonType: any; + let buttonText: string; + if (signUpMode !== SignUpMode.Default) { + buttonType = SessionButtonTypes.FullGreen; + buttonText = 'Continue Your Session'; + } else { + buttonType = SessionButtonTypes.Green; + buttonText = 'Restore Using Seed'; + } + + return ( + { + this.setState({ + signUpMode: SignUpMode.SessionIDGenerated, + }); + }} + buttonType={buttonType} + text={buttonText} + /> + ); + } + private renderSignIn() { return (
+ {this.renderRegistrationContent()} + + {this.renderSignInButtons()} + {this.getRenderTermsConditionAgreement()} +
+ ); + } + + private renderRegistrationContent() { + const { signInMode } = this.state; -
+ if (signInMode === SignInMode.UsingSeed) { + return ( +
{ i18n={this.props.i18n} value={this.state.seed} enableShowHide={true} - onValueChanged={(val: string) => this.onSeedChanged(val)} + onValueChanged={(val: string) => { + this.onSeedChanged(val); + }} /> { placeholder="Enter Optional Display Name" i18n={this.props.i18n} value={this.state.displayName} - onValueChanged={(val: string) => this.onDisplayNameChanged(val)} - + onValueChanged={(val: string) => { + this.onDisplayNameChanged(val); + }} /> this.onPasswordChanged(val)} - + onValueChanged={(val: string) => { + this.onPasswordChanged(val); + }} /> this.onPasswordVerifyChanged(val)} - + onValueChanged={(val: string) => { + this.onPasswordVerifyChanged(val); + }} /> -
+ ); + } else if (signInMode === SignInMode.LinkingDevice) { + return ( +
+
+ Open the Loki Messenger App on your primary device and select + "Device Pairing" from the main menu. Then, enter your Session ID + below to sign in. +
+ {this.renderEnterSessionID()} +
+ ); + } else { + return
; + } + } - {this.renderSignInButtons()} - {this.renderTermsConditionAgreement()} - -
); + private renderEnterSessionID() { + return ( +
+ ); } private renderSignInButtons() { @@ -202,16 +299,14 @@ export class RegistrationTabs extends React.Component { if (signInMode !== SignInMode.Default) { greenButtonType = SessionButtonTypes.FullGreen; greenText = 'Continue Your Session'; - } - else { + } else { greenButtonType = SessionButtonTypes.Green; greenText = 'Restore Using Seed'; } if (signInMode === SignInMode.LinkingDevice) { - whiteButtonText = 'Restore Using Seed' - } - else { - whiteButtonText = 'Link Device To Existing Account' + whiteButtonText = 'Restore Using Seed'; + } else { + whiteButtonText = 'Link Device To Existing Account'; } return ( @@ -219,31 +314,33 @@ export class RegistrationTabs extends React.Component { { this.setState({ - signInMode: SignInMode.UsingSeed - }) + signInMode: SignInMode.UsingSeed, + }); }} buttonType={greenButtonType} text={greenText} /> -
or
+
or
{ this.setState({ - signInMode: SignInMode.LinkingDevice - }) + signInMode: SignInMode.LinkingDevice, + }); }} buttonType={SessionButtonTypes.White} text={whiteButtonText} /> -
); +
+ ); } private renderTermsConditionAgreement() { return ( -
- By using this service, you agree to our Terms and Conditions and Privacy Statement +
+ By using this service, you agree to our Terms and Conditions and{' '} + Privacy Statement
- ) + ); // FIXME link to our Terms and Conditions and privacy statement - }; + } } diff --git a/ts/components/session/SessionRegistrationView.tsx b/ts/components/session/SessionRegistrationView.tsx index 8d7a1470f..ec5ccde06 100644 --- a/ts/components/session/SessionRegistrationView.tsx +++ b/ts/components/session/SessionRegistrationView.tsx @@ -46,9 +46,7 @@ export class SessionRegistrationView extends React.Component {
- - - +
); @@ -64,5 +62,4 @@ export class SessionRegistrationView extends React.Component { default: } } - }