Commit a717d5c8 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

udah diseseuikan dengan api

parent 40157d4c
......@@ -69,6 +69,7 @@ const globalState = {
balanceUsed:'',
pointused:'',
}
const rootReducer = (state = globalState, action) => {
......
......@@ -18,6 +18,9 @@ import ActionType from '../redux/globalActionType';
import { CommonActions } from '@react-navigation/native';
import { Ionicons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons';
import Axios from 'axios';
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import * as Device from 'expo-device';
class Account extends React.Component {
constructor(props) {
......@@ -30,14 +33,44 @@ class Account extends React.Component {
member_since: "",
account_number: "",
expire_date: "",
premium: ""
premium: "",
my_lat:0,
my_long:0
}
}
componentDidMount() {
this._getProfile();
this.props.navigation
console.log(" INI DATANYA " + this.props.set_card);
this._getPermissions()
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device')
} else {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
this.setState({
spinner: true,
})
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
})
let latitude = location.coords.latitude;
let longitude = location.coords.longitude;
this.setState({
my_lat: latitude,
my_long: longitude
})
this._getProfile()
}
logout() {
......@@ -51,11 +84,14 @@ class Account extends React.Component {
_getProfile() {
let params = {
session_id: this.props.session_id
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
console.log('ini res ' + JSON.stringify(res.data))
console.log('WAKWAWWWW ' + JSON.stringify(res.data))
const dataCard = res.data
let email = dataCard.email
let point = dataCard.kaspro_point
......@@ -66,10 +102,7 @@ class Account extends React.Component {
let premium = dataCard.kaspro_is_premium
let kaspro = dataCard.kaspro_account_number
console.log("AKUN INI : " + premium);
console.log("INI CUYYYYYY: " + kaspro)
if (kaspro === "") {
console.log('Kaspro Kosong')
let cardProps = {
set_card: false
......@@ -78,7 +111,6 @@ class Account extends React.Component {
this.props.setCardactive(cardProps)
} else {
console.log('Kaspro Isi')
let cardProps = {
set_card: true
}
......@@ -99,8 +131,6 @@ class Account extends React.Component {
premium: premium,
})
console.log(this.state.expire_date)
console.log('SET CARD NOW : ' + this.props.set_card)
}).catch(error => {
console.log('ini error ' + error)
})
......@@ -349,7 +379,6 @@ const styles = StyleSheet.create({
//subscribe
const mapStateToProps = (state) => {
console.log("INI STATEE NYA" + JSON.stringify(state));
return {
session_id: state.session_id,
set_card: state.set_card,
......
......@@ -9,13 +9,51 @@ class DeliveryAddrees extends React.Component {
constructor(props) {
super(props)
this.state = {
data: []
data: [],
outlet_id:'',
grabamount:''
}
}
componentDidMount() {
this.getAddreess()
console.log("INI ID ADDRESS : "+ this.props.addressId)
this.getRate()
console.log("INI SESSION : "+ this.props.session_id)
}
getRate() {
let params = {
session_id: this.props.session_id,
address_id: this.props.addressId,
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => {
console.log("INI LHO CUY : " + JSON.stringify(res.data.data.outlet_name))
this.setState({
outlet_id : res.data.data.outlet_id,
grabamount: res.data.data.amount,
})
let setGrabProps = {
grabdestination: this.state.grabdestination,
grabamount: this.state.grabamount,
}
this.props.setGrab(setGrabProps);
let OutletChange = {
outlet_id: this.state.outlet_id ,
}
this.props.setChangeOutletProps(OutletChange);
}).catch(error => {
console.log('ini error ' + error)
})
}
onChangeAddress = data => {
......@@ -64,7 +102,7 @@ class DeliveryAddrees extends React.Component {
'Apakah anda akan memilih alamat untuk pengiriman ?',
[
{text: 'OK', onPress: () => this.props.navigation.navigate('Menu Select')},
{text: 'OK', onPress: () => this.props.navigation.navigate('Home', { screen: 'MENU' })},
],
{ cancelable: false }
)
......@@ -184,6 +222,25 @@ const mapDispatchToProps = (dispacth) => {
addressId: setDataAddress.addressId
}
}),
setChangeOutletProps: (OutletChange) => dispacth({
type: ActionType.SET_CHANGE_OUTLET,
data: {
outlet_id: OutletChange.outlet_id,
}
}),
setGrab: (setGrabProps) => dispacth({
type: ActionType.SET_GRAB,
data: {
grabamount: setGrabProps.grabamount,
// grabpickup: setGrabProps.grabpickup,
// grabdropoff: setGrabProps.grabdropoff,
// grabdestination: setGrabProps.grabdestination,
}
}),
}
}
......
......@@ -7,6 +7,10 @@ import { connect } from 'react-redux';
import Axios from 'axios';
import i18n from 'i18n-js';
import _ from 'lodash';
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import * as Device from 'expo-device';
import ActionType from '../redux/globalActionType';
class Home extends React.Component {
......@@ -25,9 +29,10 @@ class Home extends React.Component {
}
componentDidMount() {
this._getPermissions()
this._renderCarousell()
this._account()
console.log(" ini yaaaaa"+ this.props.name_outlet)
}
//fungsi untuk get current posisi
......@@ -37,6 +42,36 @@ class Home extends React.Component {
this.state.search.clear();
};
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device')
} else {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
this.setState({
spinner: true,
})
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
})
let latitude = location.coords.latitude;
let longitude = location.coords.longitude;
this.setState({
my_lat: latitude,
my_long: longitude
})
this._account()
}
_renderCarousell() {
Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/list/promotions-carousel').then(respon => {
// console.log(respon);
......@@ -57,15 +92,30 @@ class Home extends React.Component {
_account() {
let params = {
session_id: this.props.session_id
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
}
console.log(params);
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
console.log("INI RESPON GET PROFILE : " + JSON.stringify(res))
const dataCard = res.data
let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance
let expire = dataCard.expire_date
let account_number = dataCard.kaspro_account_number
let outlet_id = dataCard.outlet_closest.outlet_id
let outlet_name = dataCard.outlet_closest.outlet_name
let OutletChange = {
outlet_id: outlet_id,
name_outlet : outlet_name
}
this.props.setChangeOutletProps(OutletChange);
this.setState({
point: point,
......@@ -139,7 +189,7 @@ class Home extends React.Component {
{i18n.t('orderInfo')}
</Text>
<Text style={{ textAlign: "center", fontSize: 12, top: 5 }}>
Excelso Senayan City
{this.props.name_outlet}
</Text>
<TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={this.onPress}>
<Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text>
......@@ -260,11 +310,26 @@ const styles = StyleSheet.create({
},
})
const mapDispatchToProps = (dispacth) => {
return {
setChangeOutletProps: (OutletChange) => dispacth({
type: ActionType.SET_CHANGE_OUTLET,
data: {
outlet_id: OutletChange.outlet_id,
name_outlet: OutletChange.name_outlet,
}
}),
}
}
const mapStateToProps = (state) => {
return {
// login
email: state.email,
outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
session_id: state.session_id,
password: state.password,
fb_token: state.fb_token,
......@@ -281,4 +346,4 @@ const mapStateToProps = (state) => {
export default connect(mapStateToProps)(Home)
\ No newline at end of file
export default connect(mapStateToProps,mapDispatchToProps)(Home)
\ No newline at end of file
......@@ -22,17 +22,19 @@ class MenuSelection extends React.Component {
}
}
componentDidMount() {
console.log("INI YA :" + this.props.outlet_id)
this.getMenuList()
}
getMenuList() {
let params = {
outlet_id: "dec1abbb-95d0-46ae-a6cd-2bf306590f15"
outlet_id: this.props.outlet_id
}
console.log("INI YA " + params)
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list', params).then(res => {
let data = res.data.data
console.log("INI DATANYA" + JSON.stringify(data))
this.setState({
listCategory: data.category,
listMenu: data.menu
......
......@@ -72,7 +72,7 @@ class PickupName extends React.Component {
}
this.props.setChangeOutletProps(OutletChange);
this.props.navigation.navigate("Menu Select")
this.props.navigation.navigate('Home', { screen: 'MENU' })
}
getOutlet() {
......
......@@ -11,6 +11,9 @@ import ItemShoping from './ItemShopingCart';
import Axios from 'axios'
import ActionType from '../redux/globalActionType';
import { YellowBox } from 'react-native';
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import * as Device from 'expo-device';
YellowBox.ignoreWarnings(['VirtualizedLists should never be nested']);
class ShoppingCart extends React.Component {
......@@ -34,12 +37,16 @@ class ShoppingCart extends React.Component {
grabpickup: '',
grabdropoff: '',
grabdestination: '',
my_lat:0,
my_long:0
// dummyBalance : 155000,
// dummyPoint : 20000
}
}
checkChangeTrans(val) {
console.log('hai lg di sini')
console.log(val)
......@@ -187,10 +194,41 @@ class ShoppingCart extends React.Component {
}
componentDidMount() {
this.getBalance()
this._getPermissions()
this.getRate()
console.log("INI PROPS"+ this.props.address)
console.log("INI PROPS" + this.props.address)
}
_getPermissions = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
Alert.alert('Akses tidak dizinkan!')
} else if (Platform.OS === 'android' && !Device.isDevice) {
Alert.alert('Silahkan anda coba di real Device')
} else {
this._getCurrentPosisition()
}
}
_getCurrentPosisition = async () => {
this.setState({
spinner: true,
})
let location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Highest
})
let latitude = location.coords.latitude;
let longitude = location.coords.longitude;
this.setState({
my_lat: latitude,
my_long: longitude
})
this.getBalance()
}
getRate() {
......@@ -233,7 +271,10 @@ class ShoppingCart extends React.Component {
getBalance() {
let params = {
session_id: this.props.session_id
session_id: this.props.session_id,
lat: this.state.my_lat,
long: this.state.my_long,
closest_outlet: 1
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
......@@ -267,7 +308,7 @@ class ShoppingCart extends React.Component {
this.state.isDelivery == true ? (
<Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text>
<Text style={{ textAlign: 'center' }}>{this.props.grabdestination}</Text>
<Text style={{ textAlign: 'center' }}>{this.props.name_outlet}</Text>
</Card>
) : (
......@@ -500,7 +541,6 @@ class ShoppingCart extends React.Component {
}
}
const styles = StyleSheet.create({
container: {
......@@ -679,6 +719,7 @@ const mapStateToProps = (state) => {
return {
session_id: state.session_id,
outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
order_quantity: state.order_quantity,
order_total: state.order_total,
order_item: state.order_item,
......
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