Commit 9851e392 authored by Trisno's avatar Trisno

benerin login

parent b721caa4
...@@ -3021,6 +3021,11 @@ ...@@ -3021,6 +3021,11 @@
"resolved": "https://registry.npmjs.org/expo-app-loader-provider/-/expo-app-loader-provider-8.0.0.tgz", "resolved": "https://registry.npmjs.org/expo-app-loader-provider/-/expo-app-loader-provider-8.0.0.tgz",
"integrity": "sha512-uMEdstZdm14JW8jfWXBWItIjGPNBH7cLj2pNu5e0pYF21W4j759rGL17NTNWit4UdLZg/zJB/HHRidVwEINfxA==" "integrity": "sha512-uMEdstZdm14JW8jfWXBWItIjGPNBH7cLj2pNu5e0pYF21W4j759rGL17NTNWit4UdLZg/zJB/HHRidVwEINfxA=="
}, },
"expo-application": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/expo-application/-/expo-application-2.0.0.tgz",
"integrity": "sha512-pRJCO6qqDOOnmc53sQD1yxO3S9OZHDjlomV7rbXdoWFTbeT2XzqlEvtApnq+V1rv4DZ/KJVrgwzcL5hkZSbLfg=="
},
"expo-asset": { "expo-asset": {
"version": "8.0.0", "version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-asset/-/expo-asset-8.0.0.tgz", "resolved": "https://registry.npmjs.org/expo-asset/-/expo-asset-8.0.0.tgz",
......
...@@ -74,7 +74,8 @@ ...@@ -74,7 +74,8 @@
"redux": "^4.0.5", "redux": "^4.0.5",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"sentry-expo": "^2.0.4" "sentry-expo": "^2.0.4",
"expo-application": "~2.0.0"
}, },
"devDependencies": { "devDependencies": {
"babel-preset-expo": "~8.0.0", "babel-preset-expo": "~8.0.0",
......
...@@ -41,7 +41,7 @@ class EmailConfirmation extends React.Component { ...@@ -41,7 +41,7 @@ class EmailConfirmation extends React.Component {
"device_id": this.props.device_id, "device_id": this.props.device_id,
"os_name": this.props.os_name, "os_name": this.props.os_name,
"os_version": this.props.os_version, "os_version": this.props.os_version,
"app_version": 'uknown', "app_version": this.props.app_version,
"verification_code": this.state.confirmation_number "verification_code": this.state.confirmation_number
} }
Axios.post(BASE_URL_LOGIN, params).then(res => { Axios.post(BASE_URL_LOGIN, params).then(res => {
......
import * as React from 'react'; import * as React from 'react';
import { Button, View, Text, TextInput, StyleSheet, Alert, Platform, Image, TouchableOpacity, StatusBar, ImageBackground,ScrollView } from 'react-native'; import { Button, View, Text, TextInput, StyleSheet, Alert, Platform, Image, TouchableOpacity, StatusBar, ImageBackground, ScrollView } from 'react-native';
import Axios from 'axios'; import Axios from 'axios';
import Constants from 'expo-constants'; import Constants from 'expo-constants';
import * as Device from 'expo-device';
import * as Permissions from 'expo-permissions';
import * as Application from 'expo-application';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import { BASE_URL_LOGIN } from '../model/Base_Model'; import { BASE_URL_LOGIN } from '../model/Base_Model';
...@@ -28,90 +31,128 @@ class Login extends React.Component { ...@@ -28,90 +31,128 @@ class Login extends React.Component {
componentDidMount() { componentDidMount() {
// console.log(this.props.language) // console.log(this.props.language)
}
async handleLoggin() { this._getDeviceInfo()
if (/\s/.test(this.state.email)) {
Alert.alert('Email tidak boleh mengandung spasi')
} else {
this.setState({
spinner: true,
})
try {
let device_id = Constants.deviceId
let os_name = Constants.platform
// let fb_token = await Notifications.getExpoPushTokenAsync();
let os_version = Platform.Version
if (this.props.device_id) {
this.setState({
device_id: this.props.device_id,
os_name: os_name,
fb_token: fb_token,
os_version: os_version,
})
} else {
let deviceInfoProps = {
device_id: device_id,
os_name: os_name,
fb_token: fb_token,
os_version: os_version,
}
// console.log(deviceInfoProps);
this.props.setDeviceInfo(deviceInfoProps)
} }
} catch (error) { _getDeviceInfo = async () => {
let { status } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
if (status !== 'granted') {
// Alert.alert('Akses tidak dizinkan!')
ToastAndroid.show("Failed to get push token for push notification!", ToastAndroid.SHORT)
} else if (Device.osName == 'Android' && !Device.isDevice) {
let device_id = Constants.deviceId // Alert.alert('Silahkan anda coba di real Device')
let os_name = Constants.platform ToastAndroid.show("Silahkan anda coba di real Device", ToastAndroid.SHORT)
} else {
let fb_token = await Notifications.getExpoPushTokenAsync(); let fb_token = await Notifications.getExpoPushTokenAsync();
let os_version = Platform.Version let device_id = Constants.deviceId
let os_name = Device.osName
if (this.props.device_id) { let os_version = Device.osVersion
this.setState({ let app_version
device_id: this.props.device_id, if (os_name == 'Android') {
os_name: os_name, app_version = Constants.platform.android.versionCode
fb_token: fb_token,
os_version: os_version,
})
} else { } else {
app_version = Constants.platform.ios.buildNumber
}
let deviceInfoProps = { let deviceInfoProps = {
device_id: device_id, device_id: device_id,
os_name: os_name, os_name: os_name,
os_version: os_version,
fb_token: fb_token, fb_token: fb_token,
os_version: os_version,
app_version: app_version
} }
// console.log(deviceInfoProps);
this.props.setDeviceInfo(deviceInfoProps) this.props.setDeviceInfo(deviceInfoProps)
}
this.state.os_name = ''; }
this.state.os_version = '';
this.state.fb_token = '';
} }
if (this.props.app_version) { async handleLoggin() {
this.setState({ if (/\s/.test(this.state.email)) {
app_version: this.props.app_version Alert.alert('Email tidak boleh mengandung spasi')
})
} else { } else {
this.setState({ this.setState({
app_version: 'Unknown' spinner: true,
}) })
} // try {
// let device_id = Constants.deviceId
// let os_name = Constants.platform
// // let fb_token = await Notifications.getExpoPushTokenAsync();
// let os_version = Platform.Version
// if (this.props.device_id) {
// this.setState({
// device_id: this.props.device_id,
// os_name: os_name,
// fb_token: fb_token,
// os_version: os_version,
// })
// } else {
// let deviceInfoProps = {
// device_id: device_id,
// os_name: os_name,
// fb_token: fb_token,
// os_version: os_version,
// }
// // console.log(deviceInfoProps);
// this.props.setDeviceInfo(deviceInfoProps)
// }
// } catch (error) {
// let device_id = Constants.deviceId
// let os_name = Constants.platform
// let fb_token = await Notifications.getExpoPushTokenAsync();
// let os_version = Platform.Version
// if (this.props.device_id) {
// this.setState({
// device_id: this.props.device_id,
// os_name: os_name,
// fb_token: fb_token,
// os_version: os_version,
// })
// } else {
// let deviceInfoProps = {
// device_id: device_id,
// os_name: os_name,
// os_version: os_version,
// fb_token: fb_token,
// }
// this.props.setDeviceInfo(deviceInfoProps)
// }
// this.state.os_name = '';
// this.state.os_version = '';
// this.state.fb_token = '';
// }
// if (this.props.app_version) {
// this.setState({
// app_version: this.props.app_version
// })
// } else {
// this.setState({
// app_version: 'Unknown'
// })
// }
//get request //get request
let params = { let params = {
"email": this.state.email, "email": this.state.email,
"password": this.state.password, "password": this.state.password,
"fb_token": this.state.fb_token, "fb_token": this.props.fb_token,
"device_id": this.state.device_id, "device_id": this.props.device_id,
"os_name": this.state.os_name, "os_name": this.props.os_name,
"os_version": this.state.os_version, "os_version": this.props.os_version,
"app_version": this.state.app_version, "app_version": this.props.app_version,
} }
// console.log(params) // console.log(params)
Axios.post(BASE_URL_LOGIN, params).then(res => { Axios.post(BASE_URL_LOGIN, params).then(res => {
...@@ -182,6 +223,11 @@ class Login extends React.Component { ...@@ -182,6 +223,11 @@ class Login extends React.Component {
} }
render() { render() {
console.log(this.props.device_id)
console.log(this.props.os_name)
console.log(this.props.fb_token)
console.log(this.props.os_version)
console.log(this.props.app_version)
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Spinner <Spinner
...@@ -200,7 +246,7 @@ class Login extends React.Component { ...@@ -200,7 +246,7 @@ class Login extends React.Component {
<View style={{ flex: 1, marginRight: 30, marginLeft: 30, justifyContent: 'center' }}> <View style={{ flex: 1, marginRight: 30, marginLeft: 30, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>Email</Text> <Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>Email</Text>
<TextInput <TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 10, borderRadius: 10,textAlign:'center', fontFamily:'Gotham-Black',color:'white',fontSize:13,fontWeight:'bold' }} style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 10, borderRadius: 10, textAlign: 'center', fontFamily: 'Gotham-Black', color: 'white', fontSize: 13, fontWeight: 'bold' }}
onChangeText={(email) => this.setState({ email })} onChangeText={(email) => this.setState({ email })}
autoCapitalize="none" autoCapitalize="none"
value={this.state.email} value={this.state.email}
...@@ -211,7 +257,7 @@ class Login extends React.Component { ...@@ -211,7 +257,7 @@ class Login extends React.Component {
<View style={{ flex: 1, height: 50, marginRight: 30, marginLeft: 30, justifyContent: 'center' }}> <View style={{ flex: 1, height: 50, marginRight: 30, marginLeft: 30, justifyContent: 'center' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>Password</Text> <Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>Password</Text>
<TextInput <TextInput
style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10,textAlign:'center',fontFamily:'Gotham-Black',color:'white',fontSize:13,fontWeight:'bold' }} style={{ height: 40, borderColor: 'gray', borderWidth: 1, padding: 5, borderRadius: 10, textAlign: 'center', fontFamily: 'Gotham-Black', color: 'white', fontSize: 13, fontWeight: 'bold' }}
onChangeText={password => this.setState({ password })} onChangeText={password => this.setState({ password })}
value={this.state.password} value={this.state.password}
secureTextEntry={true} secureTextEntry={true}
...@@ -219,7 +265,7 @@ class Login extends React.Component { ...@@ -219,7 +265,7 @@ class Login extends React.Component {
/> />
</View> </View>
<View style={{ flex: 1, height: 40, marginRight: 70, marginLeft: 70, justifyContent: 'center' }}> <View style={{ flex: 1, height: 40, marginRight: 70, marginLeft: 70, justifyContent: 'center' }}>
<TouchableOpacity onPress={()=>this.handleLoggin()}> <TouchableOpacity onPress={() => this.handleLoggin()}>
<View style={{ height: 50, borderRadius: 10, backgroundColor: '#CFB368' }}> <View style={{ height: 50, borderRadius: 10, backgroundColor: '#CFB368' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 15 }}>LOGIN</Text> <Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 15 }}>LOGIN</Text>
</View> </View>
......
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