add the basic of the create account tab and yarn lint

pull/691/head
Audric Ackermann 6 years ago
parent 5b61f9a1fc
commit e948684a83

@ -16,9 +16,14 @@ enum SignInMode {
LinkingDevice = 'LinkingDevice', LinkingDevice = 'LinkingDevice',
} }
enum SignUpMode {
Default = 'Default',
SessionIDGenerated = 'SessionIDGenerated',
}
interface State { interface State {
selectedTab: 'create' | 'signin'; selectedTab: 'create' | 'signin';
signInMode: SignInMode; signInMode: SignInMode;
signUpMode: SignUpMode;
seed: string; seed: string;
displayName: string; displayName: string;
password: string; password: string;
@ -29,8 +34,6 @@ interface TabSelectEvent {
type: 'create' | 'signin'; type: 'create' | 'signin';
} }
const Tab = ({ const Tab = ({
isSelected, isSelected,
label, label,
@ -44,8 +47,8 @@ const Tab = ({
}) => { }) => {
const handleClick = onSelect const handleClick = onSelect
? () => { ? () => {
onSelect({ type }); onSelect({ type });
} }
: undefined; : undefined;
return ( return (
@ -74,6 +77,7 @@ export class RegistrationTabs extends React.Component<Props, State> {
this.state = { this.state = {
selectedTab: 'create', selectedTab: 'create',
signInMode: SignInMode.Default, signInMode: SignInMode.Default,
signUpMode: SignUpMode.Default,
seed: '', seed: '',
displayName: '', displayName: '',
password: '', password: '',
@ -81,8 +85,6 @@ export class RegistrationTabs extends React.Component<Props, State> {
}; };
} }
public render() { public render() {
return this.renderTabs(); return this.renderTabs();
} }
@ -134,22 +136,93 @@ export class RegistrationTabs extends React.Component<Props, State> {
private renderSections() { private renderSections() {
const { selectedTab } = this.state; const { selectedTab } = this.state;
if (selectedTab === 'create') { if (selectedTab === 'create') {
return <div className="">TODO CREATE</div>; return this.renderSignUp();
} }
return this.renderSignIn(); return this.renderSignIn();
} }
private renderSignIn() { private renderSignUp() {
const { signInMode } = this.state; return (
<div className="registration-container__content">
{this.renderSignUpHeader()}
{this.renderSignUpButton()}
{this.getRenderTermsConditionAgreement()}
</div>
);
}
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 (
<div className="signup-header">
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!
</div>
);
}
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 (
<SessionButton
onClick={() => {
this.setState({
signUpMode: SignUpMode.SessionIDGenerated,
});
}}
buttonType={buttonType}
text={buttonText}
/>
);
}
private renderSignIn() {
return ( return (
<div className="registration-container__content"> <div className="registration-container__content">
{this.renderRegistrationContent()}
{this.renderSignInButtons()}
{this.getRenderTermsConditionAgreement()}
</div>
);
}
private renderRegistrationContent() {
const { signInMode } = this.state;
<div className={classNames( if (signInMode === SignInMode.UsingSeed) {
"entry-fields", return (
signInMode !== SignInMode.UsingSeed ? 'gone' : '') <div className={classNames('entry-fields')}>
}>
<SessionInput <SessionInput
label="Mnemonic Seed" label="Mnemonic Seed"
type="password" type="password"
@ -157,7 +230,9 @@ export class RegistrationTabs extends React.Component<Props, State> {
i18n={this.props.i18n} i18n={this.props.i18n}
value={this.state.seed} value={this.state.seed}
enableShowHide={true} enableShowHide={true}
onValueChanged={(val: string) => this.onSeedChanged(val)} onValueChanged={(val: string) => {
this.onSeedChanged(val);
}}
/> />
<SessionInput <SessionInput
label="Display Name" label="Display Name"
@ -165,32 +240,54 @@ export class RegistrationTabs extends React.Component<Props, State> {
placeholder="Enter Optional Display Name" placeholder="Enter Optional Display Name"
i18n={this.props.i18n} i18n={this.props.i18n}
value={this.state.displayName} value={this.state.displayName}
onValueChanged={(val: string) => this.onDisplayNameChanged(val)} onValueChanged={(val: string) => {
this.onDisplayNameChanged(val);
}}
/> />
<SessionInput <SessionInput
label="Optional Password" label="Optional Password"
type="password" type="password"
placeholder="Enter Optional Password" placeholder="Enter Optional Password"
i18n={this.props.i18n} i18n={this.props.i18n}
onValueChanged={(val: string) => this.onPasswordChanged(val)} onValueChanged={(val: string) => {
this.onPasswordChanged(val);
}}
/> />
<SessionInput <SessionInput
label="Verify Password" label="Verify Password"
type="password" type="password"
placeholder="Optional Password" placeholder="Optional Password"
i18n={this.props.i18n} i18n={this.props.i18n}
onValueChanged={(val: string) => this.onPasswordVerifyChanged(val)} onValueChanged={(val: string) => {
this.onPasswordVerifyChanged(val);
}}
/> />
</div> </div>
);
} else if (signInMode === SignInMode.LinkingDevice) {
return (
<div className="">
<div className="signin-device-pairing-header">
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.
</div>
{this.renderEnterSessionID()}
</div>
);
} else {
return <div />;
}
}
{this.renderSignInButtons()} private renderEnterSessionID() {
{this.renderTermsConditionAgreement()} return (
<div
</div>); className="signin-enter-session-id"
contentEditable={true}
placeholder="Enter your Session ID here"
/>
);
} }
private renderSignInButtons() { private renderSignInButtons() {
@ -202,16 +299,14 @@ export class RegistrationTabs extends React.Component<Props, State> {
if (signInMode !== SignInMode.Default) { if (signInMode !== SignInMode.Default) {
greenButtonType = SessionButtonTypes.FullGreen; greenButtonType = SessionButtonTypes.FullGreen;
greenText = 'Continue Your Session'; greenText = 'Continue Your Session';
} } else {
else {
greenButtonType = SessionButtonTypes.Green; greenButtonType = SessionButtonTypes.Green;
greenText = 'Restore Using Seed'; greenText = 'Restore Using Seed';
} }
if (signInMode === SignInMode.LinkingDevice) { if (signInMode === SignInMode.LinkingDevice) {
whiteButtonText = 'Restore Using Seed' whiteButtonText = 'Restore Using Seed';
} } else {
else { whiteButtonText = 'Link Device To Existing Account';
whiteButtonText = 'Link Device To Existing Account'
} }
return ( return (
@ -219,31 +314,33 @@ export class RegistrationTabs extends React.Component<Props, State> {
<SessionButton <SessionButton
onClick={() => { onClick={() => {
this.setState({ this.setState({
signInMode: SignInMode.UsingSeed signInMode: SignInMode.UsingSeed,
}) });
}} }}
buttonType={greenButtonType} buttonType={greenButtonType}
text={greenText} text={greenText}
/> />
<div className='or-signin-buttons'>or</div> <div className="or-signin-buttons">or</div>
<SessionButton <SessionButton
onClick={() => { onClick={() => {
this.setState({ this.setState({
signInMode: SignInMode.LinkingDevice signInMode: SignInMode.LinkingDevice,
}) });
}} }}
buttonType={SessionButtonTypes.White} buttonType={SessionButtonTypes.White}
text={whiteButtonText} text={whiteButtonText}
/> />
</div>); </div>
);
} }
private renderTermsConditionAgreement() { private renderTermsConditionAgreement() {
return ( return (
<div className='terms-conditions-agreement'> <div className="terms-conditions-agreement">
By using this service, you agree to our <a>Terms and Conditions</a> and <a>Privacy Statement</a> By using this service, you agree to our <a>Terms and Conditions</a> and{' '}
<a>Privacy Statement</a>
</div> </div>
) );
// FIXME link to our Terms and Conditions and privacy statement // FIXME link to our Terms and Conditions and privacy statement
}; }
} }

@ -46,9 +46,7 @@ export class SessionRegistrationView extends React.Component<Props> {
<AccentText showSubtitle={showSubtitle || true} /> <AccentText showSubtitle={showSubtitle || true} />
</div> </div>
<div className="session-content-registration"> <div className="session-content-registration">
<RegistrationTabs i18n={i18n} > <RegistrationTabs i18n={i18n} />
</RegistrationTabs>
</div> </div>
</div> </div>
); );
@ -64,5 +62,4 @@ export class SessionRegistrationView extends React.Component<Props> {
default: default:
} }
} }
} }

Loading…
Cancel
Save