Commit b3b8fbe2 authored by d.arizona's avatar d.arizona

update token

parent e50f7867
import React, { Component } from 'react'
import { ScrollView, Text, KeyboardAvoidingView, BackHandler, Alert, View, TouchableOpacity, Image, NativeModules, Platform, TextInput} from 'react-native'
import { ScrollView, Text, KeyboardAvoidingView, BackHandler, Alert, View, TouchableOpacity, Image, NativeModules, Platform, TextInput, AsyncStorage} from 'react-native'
import { connect } from 'react-redux'
import FontAwesome from 'react-native-vector-icons/FontAwesome'
import Ionicons from 'react-native-vector-icons/Ionicons'
import Toast from 'react-native-toast-message'
import R from 'ramda'
import AuthAction from '../Redux/AuthRedux'
import Constants from '../Lib/Constants'
// Add Actions - replace 'Your' with whatever your reducer is called :)
// import YourActions from '../Redux/YourRedux'
const { StatusBarManager } = NativeModules;
......@@ -76,6 +77,7 @@ class LoginScreen extends Component {
this.props.navigation.navigate('OtpVerificationScreen')
}
if (!auth.error) {
AsyncStorage.setItem(Constants.TOKEN, auth.user.data.token)
this.props.navigation.navigate('HomeNavigation')
}
// auth.error? null : (
......
import React, { Component } from 'react'
import { ScrollView, Text, KeyboardAvoidingView, View, Image, TextInput, Keyboard, BackHandler } from 'react-native'
import { ScrollView, Text, KeyboardAvoidingView, View, Image, TextInput, Keyboard, BackHandler, AsyncStorage } from 'react-native'
import { connect } from 'react-redux'
import AuthAction from '../Redux/AuthRedux'
// Add Actions - replace 'Your' with whatever your reducer is called :)
......@@ -15,6 +15,7 @@ import BaseButton from '../Components/BaseButton'
import { StackActions, NavigationActions } from 'react-navigation'
import Api from '../Services/Api'
import Toast from 'react-native-toast-message'
import Constants from '../Lib/Constants'
class OtpVerificationScreen extends Component {
constructor(props) {
......@@ -92,6 +93,9 @@ class OtpVerificationScreen extends Component {
// topOffset: 100,
// bottomOffset: 40,
})
if (auth.error == 'success') {
AsyncStorage.setItem(Constants.TOKEN, auth.user.data.token)
}
auth.error? null : this.handleVerif()
}
}
......
import React, { Component } from 'react'
import { ScrollView, Text, KeyboardAvoidingView, Image, View, BackHandler, TouchableOpacity, StatusBar } from 'react-native'
import { ScrollView, Text, KeyboardAvoidingView, Image, View, BackHandler, TouchableOpacity, StatusBar, AsyncStorage } from 'react-native'
import { connect } from 'react-redux'
import { withNavigationFocus, NavigationEvents } from 'react-navigation';
// Add Actions - replace 'Your' with whatever your reducer is called :)
......@@ -16,7 +16,7 @@ class ProfileScreen extends Component {
super(props)
this.state = {
// activeIndex: this.props.activeIndex
data: this.props.auth.user.data
data: this.props.auth
}
}
backAction = () => {
......@@ -27,7 +27,6 @@ class ProfileScreen extends Component {
componentDidMount() {
BackHandler.addEventListener("hardwareBackPress", this.backAction);
// console.log('auth', this.props.auth.user.data)
}
componentWillUnmount() {
......@@ -35,11 +34,13 @@ class ProfileScreen extends Component {
}
getDataProfile() {
console.log('auth', this.props.auth.user.data)
if (this.state.data !== null) {
console.log('auth', this.props.auth.user.data)
this.setState({
data: this.props.auth.user.data
})
this.setState({
data: this.props.auth.user.data
})
}
}
render() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment