Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename and restyle set password form #2211

Merged
merged 26 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
075c60d
Rename the SetPasswordPage => SetPasswordForm, change its styles to m…
jasperhuangg Apr 2, 2021
eb68583
Fix missing handler
jasperhuangg Apr 2, 2021
07a0cd4
Change SignInPageLayout to use SafeAreaView
jasperhuangg Apr 2, 2021
bd56c30
Change SignInPageLayout to use SafeAreaView
jasperhuangg Apr 2, 2021
fbc5a25
Fix style, remove unused
jasperhuangg Apr 2, 2021
5c4a3d1
merge from jasper-fixLoginForm
jasperhuangg Apr 5, 2021
4ee23f7
Fix JSX
jasperhuangg Apr 5, 2021
aef86c3
Merge master
jasperhuangg Apr 13, 2021
01eafbb
merge master
jasperhuangg Apr 20, 2021
10c3d07
merge main
jasperhuangg Apr 20, 2021
a9a8dfb
autoFocus conditionally
jasperhuangg Apr 20, 2021
775084c
Fix form values
jasperhuangg Apr 20, 2021
8d4bff6
Add accountID to route
jasperhuangg Apr 21, 2021
2ddd8ca
Merge branch 'main' of github.com:Expensify/Expensify.cash into jaspe…
jasperhuangg Apr 21, 2021
1595ee4
Wrap narrow/wide SignInPageLayout with SafeAreaView
jasperhuangg Apr 21, 2021
dfe45d9
Change SafeAreaView placement
jasperhuangg Apr 21, 2021
d2ba95f
Revert unneeded change
jasperhuangg Apr 22, 2021
893b7ef
Remove unused
jasperhuangg Apr 22, 2021
8396bbe
Revert renaming of file
jasperhuangg Apr 22, 2021
58476dd
Revert proptypes change.
jasperhuangg Apr 26, 2021
6e72087
Remove windowDimensions from SignInPage.js
jasperhuangg Apr 26, 2021
f7c0dc7
Revert new line
jasperhuangg Apr 27, 2021
b3adcef
Remove unnecessary compose
jasperhuangg Apr 27, 2021
245cb91
Move import back
jasperhuangg Apr 27, 2021
d0a6d1d
Move import back
jasperhuangg Apr 27, 2021
ea0e16f
Merge branch 'main' into jasper-fixSetPasswordPage
jasperhuangg Apr 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libs/Navigation/AppNavigator/PublicScreens.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {createStackNavigator} from '@react-navigation/stack';
import SignInPage from '../../../pages/signin/SignInPage';
import SetPasswordPage from '../../../pages/SetPasswordPage';
import SetPasswordForm from '../../../pages/SetPasswordForm';
import ValidateLoginPage from '../../../pages/ValidateLoginPage';
import SCREENS from '../../../SCREENS';

Expand Down Expand Up @@ -29,7 +29,7 @@ export default () => (
<RootStack.Screen
name="SetPassword"
options={defaultScreenOptions}
component={SetPasswordPage}
component={SetPasswordForm}
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
/>
</RootStack.Navigator>
);
140 changes: 140 additions & 0 deletions src/pages/SetPasswordForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import React, {Component} from 'react';
import {
Text,
TextInput,
View,
SafeAreaView,
} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import styles from '../styles/styles';
import {setPassword} from '../libs/actions/Session';
import ONYXKEYS from '../ONYXKEYS';
import ButtonWithLoader from '../components/ButtonWithLoader';
import themeColors from '../styles/themes/default';
import SignInPageLayout from './signin/SignInPageLayout';
import canFocusInputOnScreenFocus from '../libs/canFocusInputOnScreenFocus';

const propTypes = {
/* Onyx Props */

// The details about the account that the user is signing in with
account: PropTypes.shape({
// An error message to display to the user
error: PropTypes.string,

// Whether or not a sign on form is loading (being submitted)
loading: PropTypes.bool,
}),

// The credentials of the logged in person
credentials: PropTypes.shape({
// The email the user logged in with
login: PropTypes.string,

// The password used to log in the user
password: PropTypes.string,
}),

route: PropTypes.shape({
params: PropTypes.shape({
accountID: PropTypes.string,
validateCode: PropTypes.string,
}),
}),
};

const defaultProps = {
account: {},
credentials: {},
route: {
params: {},
},
};

class SetPasswordForm extends Component {
constructor(props) {
super(props);

this.validateAndSubmitForm = this.validateAndSubmitForm.bind(this);

this.state = {
password: '',
formError: null,
};
}

/**
* Validate the form and then submit it
*/
validateAndSubmitForm() {
if (!this.state.password.trim()) {
this.setState({
formError: 'Password cannot be blank',
});
return;
}

this.setState({
formError: null,
});
setPassword(
this.state.password,
lodashGet(this.props.route, 'params.validateCode', ''),
lodashGet(this.props.route, 'params.accountID', ''),
);
}

render() {
return (
<SafeAreaView style={[styles.signInPage]}>
<SignInPageLayout>
<View style={[styles.mb4]}>
<Text style={[styles.formLabel]}>Enter a password:</Text>
<TextInput
style={[styles.textInput]}
value={this.state.password}
secureTextEntry
autoCompleteType="password"
textContentType="password"
onChangeText={text => this.setState({password: text})}
onSubmitEditing={this.validateAndSubmitForm}
autoCapitalize="none"
placeholderTextColor={themeColors.placeholderText}
autoFocus={canFocusInputOnScreenFocus()}
/>
</View>
<View>
<ButtonWithLoader
text="Set Password"
isLoading={this.props.account.loading}
onClick={this.validateAndSubmitForm}
/>
</View>

{this.state.formError && (
<Text style={[styles.formError]}>
{this.state.formError}
</Text>
)}

{!_.isEmpty(this.props.account.error) && (
<Text style={[styles.formError]}>
{this.props.account.error}
</Text>
)}
</SignInPageLayout>
</SafeAreaView>
);
}
}

SetPasswordForm.propTypes = propTypes;
SetPasswordForm.defaultProps = defaultProps;

export default withOnyx({
credentials: {key: ONYXKEYS.CREDENTIALS},
account: {key: ONYXKEYS.ACCOUNT},
})(SetPasswordForm);
139 changes: 0 additions & 139 deletions src/pages/SetPasswordPage.js

This file was deleted.

17 changes: 12 additions & 5 deletions src/pages/signin/SignInPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import SignInPageLayout from './SignInPageLayout';
import LoginForm from './LoginForm';
import PasswordForm from './PasswordForm';
import ResendValidationForm from './ResendValidationForm';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import compose from '../../libs/compose';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -43,6 +45,8 @@ const propTypes = {
// Error to display when there is a session error returned
authToken: PropTypes.string,
}),

...windowDimensionsPropTypes,
};

const defaultProps = {
Expand Down Expand Up @@ -114,8 +118,11 @@ class SignInPage extends Component {
SignInPage.propTypes = propTypes;
SignInPage.defaultProps = defaultProps;

export default withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
credentials: {key: ONYXKEYS.CREDENTIALS},
session: {key: ONYXKEYS.SESSION},
})(SignInPage);
export default compose(
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
credentials: {key: ONYXKEYS.CREDENTIALS},
session: {key: ONYXKEYS.SESSION},
}),
withWindowDimensions,
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
)(SignInPage);
3 changes: 3 additions & 0 deletions src/pages/signin/SignInPageLayout/SignInPageLayoutNarrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import variables from '../../../styles/variables';
import ExpensifyCashLogo from '../../../../assets/images/expensify-cash.svg';
import welcomeScreenshot from '../../../../assets/images/welcome-screenshot.png';
import TermsAndLicenses from '../TermsAndLicenses';
import {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import WelcomeText from '../../../components/WelcomeText';

const propTypes = {

...windowDimensionsPropTypes,

jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
// The children to show inside the layout
children: PropTypes.node.isRequired,

Expand Down
4 changes: 3 additions & 1 deletion src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import {
Image, Text, View,
Image,
Text,
View,
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../../styles/styles';
Expand Down