Commit 9851e392 authored by Trisno's avatar Trisno

benerin login

parent b721caa4
......@@ -3021,6 +3021,11 @@
"resolved": "https://registry.npmjs.org/expo-app-loader-provider/-/expo-app-loader-provider-8.0.0.tgz",
"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": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/expo-asset/-/expo-asset-8.0.0.tgz",
......
......@@ -74,7 +74,8 @@
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"sentry-expo": "^2.0.4"
"sentry-expo": "^2.0.4",
"expo-application": "~2.0.0"
},
"devDependencies": {
"babel-preset-expo": "~8.0.0",
......
......@@ -41,7 +41,7 @@ class EmailConfirmation extends React.Component {
"device_id": this.props.device_id,
"os_name": this.props.os_name,
"os_version": this.props.os_version,
"app_version": 'uknown',
"app_version": this.props.app_version,
"verification_code": this.state.confirmation_number
}
Axios.post(BASE_URL_LOGIN, params).then(res => {
......
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 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 ActionType from '../redux/globalActionType';
import { BASE_URL_LOGIN } from '../model/Base_Model';
......@@ -28,6 +31,44 @@ class Login extends React.Component {
componentDidMount() {
// console.log(this.props.language)
this._getDeviceInfo()
}
_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) {
// Alert.alert('Silahkan anda coba di real Device')
ToastAndroid.show("Silahkan anda coba di real Device", ToastAndroid.SHORT)
} else {
let fb_token = await Notifications.getExpoPushTokenAsync();
let device_id = Constants.deviceId
let os_name = Device.osName
let os_version = Device.osVersion
let app_version
if (os_name == 'Android') {
app_version = Constants.platform.android.versionCode
} else {
app_version = Constants.platform.ios.buildNumber
}
let deviceInfoProps = {
device_id: device_id,
os_name: os_name,
fb_token: fb_token,
os_version: os_version,
app_version: app_version
}
// console.log(deviceInfoProps);
this.props.setDeviceInfo(deviceInfoProps)
}
}
async handleLoggin() {
......@@ -37,81 +78,81 @@ class Login extends React.Component {
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) {
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'
})
}
// 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
let params = {
"email": this.state.email,
"password": this.state.password,
"fb_token": this.state.fb_token,
"device_id": this.state.device_id,
"os_name": this.state.os_name,
"os_version": this.state.os_version,
"app_version": this.state.app_version,
"fb_token": this.props.fb_token,
"device_id": this.props.device_id,
"os_name": this.props.os_name,
"os_version": this.props.os_version,
"app_version": this.props.app_version,
}
// console.log(params)
Axios.post(BASE_URL_LOGIN, params).then(res => {
......@@ -182,16 +223,21 @@ class Login extends React.Component {
}
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 (
<View style={styles.container}>
<Spinner
visible={this.state.spinner}
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/>
<Spinner
visible={this.state.spinner}
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/>
<StatusBar
hidden={true} />
<ImageBackground source={require('../assets/images/loging-background.jpg')} style={{ width: '100%', height: '100%' }}>
<View style={styles.logo}>
<Image source={require('../assets/images/excelso-log.png')} style={styles.imageslogo}></Image>
......@@ -200,7 +246,7 @@ class Login extends React.Component {
<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>
<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 })}
autoCapitalize="none"
value={this.state.email}
......@@ -211,7 +257,7 @@ class Login extends React.Component {
<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>
<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 })}
value={this.state.password}
secureTextEntry={true}
......@@ -219,7 +265,7 @@ class Login extends React.Component {
/>
</View>
<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' }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', margin: 15 }}>LOGIN</Text>
</View>
......@@ -228,16 +274,16 @@ class Login extends React.Component {
</View>
<View style={styles.v_policy}>
<View style={{ flex: 1, justifyContent: 'center' }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('New Register')}>
<Text style={{ fontFamily: 'Gotham-Light', color: '#CFB368', fontSize: 16, textAlign: 'center', marginBottom: 5 }}>REGISTER</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Reset Password')}>
<Text style={{ fontFamily: 'Gotham-Light', color: '#CFB368', fontSize: 16, textAlign: 'center', marginTop: 5 }}>FORGOT PASSWORD</Text>
<TouchableOpacity onPress={() => this.props.navigation.navigate('New Register')}>
<Text style={{ fontFamily: 'Gotham-Light', color: '#CFB368', fontSize: 16, textAlign: 'center', marginBottom: 5 }}>REGISTER</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Reset Password')}>
<Text style={{ fontFamily: 'Gotham-Light', color: '#CFB368', fontSize: 16, textAlign: 'center', marginTop: 5 }}>FORGOT PASSWORD</Text>
</TouchableOpacity>
</View>
<View style={{ flex: 1, justifyContent: 'center', marginRight: 60, marginLeft: 60 }}>
<View style={{ flex: 1, justifyContent: 'center', marginRight: 60, marginLeft: 60 }}>
<Text style={{ fontFamily: 'Gotham-Light', color: '#CFB368', fontSize: 13, textAlign: 'center', marginBottom: 5 }}>
Dengan Login atau Register, Kamu menyetujui aturan <Text style={{ fontWeight: 'bold' }}> Panduan Layanan</Text> dan <Text style={{ fontWeight: 'bold' }}>Kebijakan Privasi kami</Text>
</Text>
......
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