mirror of
https://github.com/Telecominfraproject/wlan-sdk-mobile-app.git
synced 2025-11-03 04:08:04 +00:00
Forgot password activity indicator
This commit is contained in:
@@ -14,11 +14,15 @@ export const strings = new LocalizedStrings({
|
|||||||
token: 'Credentials no longer valid, please sign-in again.',
|
token: 'Credentials no longer valid, please sign-in again.',
|
||||||
internal: 'Internal error.',
|
internal: 'Internal error.',
|
||||||
unknown: 'Unknown error.',
|
unknown: 'Unknown error.',
|
||||||
|
emptyFields: 'Please fill in all fields',
|
||||||
|
samePassword: 'Password is the same as old password.',
|
||||||
|
mismatchPassword: 'Password mismatch.',
|
||||||
},
|
},
|
||||||
placeholders: {
|
placeholders: {
|
||||||
username: 'Username',
|
username: 'Username',
|
||||||
password: 'Password',
|
password: 'Password',
|
||||||
newPassword: 'New Password',
|
newPassword: 'New Password',
|
||||||
|
confirmPassword: 'Confirm Password',
|
||||||
email: 'Email',
|
email: 'Email',
|
||||||
},
|
},
|
||||||
buttons: {
|
buttons: {
|
||||||
@@ -27,8 +31,10 @@ export const strings = new LocalizedStrings({
|
|||||||
signOut: 'Sign Out',
|
signOut: 'Sign Out',
|
||||||
sendEmail: 'Send Email',
|
sendEmail: 'Send Email',
|
||||||
submit: 'Submit',
|
submit: 'Submit',
|
||||||
|
cancel: 'Cancel',
|
||||||
},
|
},
|
||||||
messages: {
|
messages: {
|
||||||
|
message: 'Message',
|
||||||
resetEmail:
|
resetEmail:
|
||||||
"You should soon receive an email containing the instructions to reset your password. Please make sure to check your spam if you can't find the email.",
|
"You should soon receive an email containing the instructions to reset your password. Please make sure to check your spam if you can't find the email.",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {pageStyle, pageItemStyle} from '../AppStyle';
|
import {pageStyle, pageItemStyle} from '../AppStyle';
|
||||||
import {View, Text, TextInput, Button} from 'react-native';
|
import { View, Text, TextInput, Button, ActivityIndicator, Alert } from "react-native";
|
||||||
import {strings} from '../localization/LocalizationStrings';
|
import {strings} from '../localization/LocalizationStrings';
|
||||||
import {authenticationApi, handleApiError} from '../api/apiHandler';
|
import {authenticationApi, handleApiError} from '../api/apiHandler';
|
||||||
import {useStore} from '../Store';
|
import {useStore} from '../Store';
|
||||||
@@ -8,7 +8,7 @@ import {useStore} from '../Store';
|
|||||||
export default class ForgotPassword extends Component {
|
export default class ForgotPassword extends Component {
|
||||||
state = {
|
state = {
|
||||||
email: '',
|
email: '',
|
||||||
sent: false,
|
loading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -28,13 +28,20 @@ export default class ForgotPassword extends Component {
|
|||||||
textContentType="emailAddress"
|
textContentType="emailAddress"
|
||||||
returnKeyType="go"
|
returnKeyType="go"
|
||||||
onChangeText={text => this.setState({email: text})}
|
onChangeText={text => this.setState({email: text})}
|
||||||
onSubmitEditing={this.onSubmit}
|
onSubmitEditing={() => {this.state.email && this.onSubmit}}
|
||||||
/>
|
/>
|
||||||
<Text>{this.state.sent && strings.messages.resetEmail}</Text>
|
|
||||||
</View>
|
</View>
|
||||||
|
<View style={pageItemStyle.container}>
|
||||||
|
<ActivityIndicator size="large" animating={this.state.loading} />
|
||||||
|
</View>
|
||||||
|
{this.state.loading ||
|
||||||
<View style={pageItemStyle.containerButton}>
|
<View style={pageItemStyle.containerButton}>
|
||||||
<Button title={strings.buttons.sendEmail} onPress={this.onSubmit} />
|
<Button title={strings.buttons.sendEmail}
|
||||||
|
onPress={this.onSubmit}
|
||||||
|
disabled={!this.state.email}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
}
|
||||||
<View style={pageItemStyle.containerButton}>
|
<View style={pageItemStyle.containerButton}>
|
||||||
<Button title={strings.buttons.signIn} onPress={this.backToSignin} />
|
<Button title={strings.buttons.signIn} onPress={this.backToSignin} />
|
||||||
</View>
|
</View>
|
||||||
@@ -43,6 +50,7 @@ export default class ForgotPassword extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSubmit = async () => {
|
onSubmit = async () => {
|
||||||
|
this.setState({loading: true});
|
||||||
try {
|
try {
|
||||||
useStore.getState().clearSession();
|
useStore.getState().clearSession();
|
||||||
|
|
||||||
@@ -53,11 +61,12 @@ export default class ForgotPassword extends Component {
|
|||||||
undefined,
|
undefined,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
console.log(JSON.stringify(response, null, '\t'));
|
// console.log(JSON.stringify(response.data, null, '\t'));
|
||||||
this.setState({sent: true});
|
Alert.alert(strings.messages.message, strings.messages.resetEmail);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleApiError(strings.errors.forgotPasswordTitle, error);
|
handleApiError(strings.errors.forgotPasswordTitle, error);
|
||||||
}
|
}
|
||||||
|
this.setState({loading: false});
|
||||||
};
|
};
|
||||||
|
|
||||||
backToSignin = () => {
|
backToSignin = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user