Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
13 changes: 13 additions & 0 deletions packages/rn-api/src/models/user/PasswordModel.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this model should be the ApiResponseModel and the PasswordModal will inherit from it

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default class PasswordModel {
constructor(message, errorCode, data, isSuccess) {
this.message = message
this.errorCode = errorCode
this.data = data
this.isSuccess = isSuccess
}

static parseFromJson = payload => {
const {message, errorCode, data, isSuccess} = payload
return new PasswordModel(message, errorCode, data, isSuccess)
}
}
3 changes: 3 additions & 0 deletions packages/rn-api/src/navigation/RouteKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default {
LoginScreen: 'LoginScreen',
SignUpScreen: 'SignUpScreen',
HomeScreen: 'HomeScreen',
ForgotPasswordScreen: 'ForgotPasswordScreen',
ResetPasswordScreen: 'ResetPasswordScreen',
ChangePasswordScreen: 'ChangePasswordScreen',

/** Stack */
AuthStack: 'AuthStack',
Expand Down
14 changes: 13 additions & 1 deletion packages/rn-api/src/navigation/ScreenService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import RouteKey from './RouteKey'
import {SignUpScreen, LoginScreen} from '../screens'
import {
SignUpScreen,
LoginScreen,
ForgotPasswordScreen,
ResetPasswordScreen,
ChangePasswordScreen,
} from '../screens'
// Screen Import
import HomeScreen from '../screens/HomeComponent/HomeScreen'
import {colors} from '../themes'
Expand All @@ -13,6 +19,12 @@ export const screenMatch = screen => {
return SignUpScreen
case RouteKey.HomeScreen:
return HomeScreen
case RouteKey.ForgotPasswordScreen:
return ForgotPasswordScreen
case RouteKey.ResetPasswordScreen:
return ResetPasswordScreen
case RouteKey.ChangePasswordScreen:
return ChangePasswordScreen
default:
return ''
}
Expand Down
15 changes: 15 additions & 0 deletions packages/rn-api/src/navigation/StackNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ export const AuthNavigator = () => (
component={screenMatch(RouteKey.SignUpScreen)}
options={optionsMatch}
/>
<Stack.Screen
name={RouteKey.ForgotPasswordScreen}
component={screenMatch(RouteKey.ForgotPasswordScreen)}
options={optionsMatch}
/>
<Stack.Screen
name={RouteKey.ResetPasswordScreen}
component={screenMatch(RouteKey.ResetPasswordScreen)}
options={optionsMatch}
/>
<Stack.Screen
name={RouteKey.ChangePasswordScreen}
component={screenMatch(RouteKey.ChangePasswordScreen)}
options={optionsMatch}
/>
</Stack.Navigator>
)

Expand Down
97 changes: 97 additions & 0 deletions packages/rn-api/src/screens/AuthComponent/ChangePasswordScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React, {useCallback, useReducer} from 'react'
import {ScreenContainer} from '../../components/ScreenContainer'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {Text, StyleSheet, View, TouchableOpacity} from 'react-native'
import PasswordInput from '../../components/InputPassword'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {responsiveHeight} from '../../themes/metrics'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {colors} from '../../themes'
import {useDispatch} from 'react-redux'
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view'
import {userActions} from '../../store/reducers'

export const ChangePasswordScreen = () => {
const dispatch = useDispatch()
const [inputValue, setInputValue] = useReducer((prev, next) => ({...prev, ...next}), {
newPassword: '',
confirmPassword: '',
oldPassword: '',
})

const onSaveChangePassword = useCallback(() => {
dispatch(
userActions.changePasswordHandle({
newPassword: inputValue.newPassword,
confirmPassword: inputValue.confirmPassword,
oldPassword: inputValue.oldPassword,
}),
)
}, [inputValue, dispatch])

const onChangeNewPass = useCallback(text => {
setInputValue({newPassword: text})
}, [])

const onChangePassword = useCallback(text => {
setInputValue({confirmPassword: text})
}, [])

const onChangeOldPassword = useCallback(text => {
setInputValue({oldPassword: text})
}, [])

return (
<ScreenContainer style={styles.container}>
<KeyboardAwareScrollView>
<Text style={styles.titleText}>Change Password</Text>
<PasswordInput onChangeText={onChangeNewPass} defaultValue={inputValue.id} title={'New Password'} />
<View style={styles.passwordSection}>
<PasswordInput
onChangeText={onChangePassword}
defaultValue={inputValue.password}
title="Confirm Password"
/>
</View>
<View style={styles.passwordSection}>
<PasswordInput
onChangeText={onChangeOldPassword}
defaultValue={inputValue.password}
title="Old Password"
/>
</View>
<TouchableOpacity style={styles.button} onPress={onSaveChangePassword}>
<Text>SAVE</Text>
</TouchableOpacity>
</KeyboardAwareScrollView>
</ScreenContainer>
)
}

const styles = StyleSheet.create({
container: {
padding: responsiveHeight(10),
alignItems: 'center',
},
titleText: {
fontSize: responsiveHeight(25),
fontWeight: '600',
marginVertical: responsiveHeight(20),
},
passwordSection: {
marginTop: responsiveHeight(10),
},
button: {
backgroundColor: colors.primary,
width: '100%',
height: responsiveHeight(40),
marginTop: responsiveHeight(10),
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
},
forgotPassword: {
fontSize: responsiveHeight(18),
marginVertical: responsiveHeight(10),
alignSelf: 'flex-end',
color: colors.primary,
textDecorationLine: 'underline',
},
})
68 changes: 68 additions & 0 deletions packages/rn-api/src/screens/AuthComponent/ForgotPasswordScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, {useCallback, useState} from 'react'
import {ScreenContainer} from '../../components/ScreenContainer'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {Text, StyleSheet, TouchableOpacity} from 'react-native'
import {responsiveHeight} from '../../themes/metrics'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {colors} from '../../themes'
import {useDispatch} from 'react-redux'
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view'
import {userActions} from '../../store/reducers'
import InputWithLabel from '../../components/InputWithLabel'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


export const ForgotPasswordScreen = () => {
const dispatch = useDispatch()
const [email, setEmail] = useState('')

const onForgotPassword = useCallback(() => {
dispatch(userActions.forgotPasswordHandle({email}))
}, [email, dispatch])

const onChangeEmail = useCallback(text => {
setEmail(text)
}, [])

return (
<ScreenContainer style={styles.container}>
<KeyboardAwareScrollView style={styles.contentSection}>
<Text style={styles.titleText}>Forgot Password</Text>
<InputWithLabel onChangeText={onChangeEmail} defaultValue={email} title={'Email'} />
<TouchableOpacity style={styles.button} onPress={onForgotPassword}>
<Text>SAVE</Text>
</TouchableOpacity>
</KeyboardAwareScrollView>
</ScreenContainer>
)
}

const styles = StyleSheet.create({
container: {
padding: responsiveHeight(10),
alignItems: 'center',
},
contentSection: {
width: '100%',
},
titleText: {
fontSize: responsiveHeight(25),
fontWeight: '600',
marginVertical: responsiveHeight(20),
},
passwordSection: {
marginTop: responsiveHeight(10),
},
button: {
backgroundColor: colors.primary,
width: '100%',
height: responsiveHeight(40),
marginTop: responsiveHeight(10),
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
},
forgotPassword: {
fontSize: responsiveHeight(18),
marginVertical: responsiveHeight(10),
alignSelf: 'flex-end',
color: colors.primary,
textDecorationLine: 'underline',
},
})
98 changes: 95 additions & 3 deletions packages/rn-api/src/screens/AuthComponent/LoginScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,96 @@
import React from 'react'
import {ScreenContainer} from '../../components'
import React, {useCallback, useReducer} from 'react'
import {ScreenContainer} from '../../components/ScreenContainer'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {Text, StyleSheet, View, TouchableOpacity} from 'react-native'
import PasswordInput from '../../components/InputPassword'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {responsiveHeight} from '../../themes/metrics'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import {colors} from '../../themes'
import {useDispatch} from 'react-redux'
import {KeyboardAwareScrollView} from 'react-native-keyboard-aware-scroll-view'
import {userActions} from '../../store/reducers'
import {navigate} from '../../navigation/NavigationService'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import RouteKey from '../../navigation/RouteKey'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

import InputWithLabel from '../../components/InputWithLabel'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shorten import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


export const LoginScreen = () => <ScreenContainer />
export const LoginScreen = () => {
const dispatch = useDispatch()
const [inputValue, setInputValue] = useReducer((prev, next) => ({...prev, ...next}), {
email: '',
password: '',
})

const onPressLogin = useCallback(() => {
dispatch(userActions.userLogin())
}, [dispatch])

const onChangeEmail = useCallback(text => {
setInputValue({email: text})
}, [])

const onChangePassword = useCallback(text => {
setInputValue({password: text})
}, [])

return (
<ScreenContainer style={styles.container}>
<KeyboardAwareScrollView>
<Text style={styles.titleText}>Login Screen</Text>
<InputWithLabel onChangeText={onChangeEmail} value={inputValue.id} title={'Email'} />
<View style={styles.passwordSection}>
<PasswordInput onChangeText={onChangePassword} value={inputValue.password} title="Password" />
</View>
<TouchableOpacity
onPress={() => {
navigate(RouteKey.ChangePasswordScreen)
}}>
<Text style={styles.forgotPassword}>Change Password</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
navigate(RouteKey.ForgotPasswordScreen)
}}>
<Text style={styles.forgotPassword}>Forgot Password</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => {
navigate(RouteKey.ResetPasswordScreen)
}}>
<Text style={styles.forgotPassword}>Reset Password</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.button} onPress={onPressLogin}>
<Text>SAVE</Text>
</TouchableOpacity>
</KeyboardAwareScrollView>
</ScreenContainer>
)
}

const styles = StyleSheet.create({
container: {
padding: responsiveHeight(10),
alignItems: 'center',
},
titleText: {
fontSize: responsiveHeight(25),
fontWeight: '600',
marginVertical: responsiveHeight(20),
},
passwordSection: {
marginTop: responsiveHeight(10),
},
button: {
backgroundColor: colors.primary,
width: '100%',
height: responsiveHeight(40),
marginTop: responsiveHeight(10),
alignItems: 'center',
justifyContent: 'center',
borderRadius: 10,
},
forgotPassword: {
fontSize: responsiveHeight(18),
marginVertical: responsiveHeight(10),
alignSelf: 'flex-end',
color: colors.primary,
textDecorationLine: 'underline',
},
})
Loading