diff options
Diffstat (limited to 'src/screens/onboarding/Login.tsx')
| -rw-r--r-- | src/screens/onboarding/Login.tsx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/screens/onboarding/Login.tsx b/src/screens/onboarding/Login.tsx index 8f19ec3d..2ddae403 100644 --- a/src/screens/onboarding/Login.tsx +++ b/src/screens/onboarding/Login.tsx @@ -14,11 +14,12 @@ import { } from 'react-native'; import {OnboardingStackParams} from '../../routes/onboarding'; -import {AuthContext} from '../../routes/authentication'; import {Background, TaggInput, SubmitButton} from '../../components'; import {usernameRegex, LOGIN_ENDPOINT} from '../../constants'; import AsyncStorage from '@react-native-community/async-storage'; import {UserType} from '../../types'; +import {useDispatch} from 'react-redux'; +import {userLogin} from '../../utils'; type VerificationScreenRouteProp = RouteProp<OnboardingStackParams, 'Login'>; type VerificationScreenNavigationProp = StackNavigationProp< @@ -51,9 +52,15 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { attemptedSubmit: false, token: '', }); - // determines if user is logged in - const {login} = React.useContext(AuthContext); const [user, setUser] = useState<UserType>(NO_USER); + + /** + * Redux Store stuff + * Get the dispatch reference + */ + + const dispatch = useDispatch(); + /** * Updates the state of username. Also verifies the input of the username field by ensuring proper length and appropriate characters. */ @@ -140,7 +147,7 @@ const Login: React.FC<LoginProps> = ({navigation}: LoginProps) => { await AsyncStorage.setItem('token', data.token); await AsyncStorage.setItem('userId', data.UserID); await AsyncStorage.setItem('username', username); - login(data.UserID, username); + userLogin(dispatch, {userId: data.UserID, username}); } catch (err) { setUser(NO_USER); console.log(data); |
