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

udah diseseuikan dengan api

parent 40157d4c
...@@ -69,6 +69,7 @@ const globalState = { ...@@ -69,6 +69,7 @@ const globalState = {
balanceUsed:'', balanceUsed:'',
pointused:'', pointused:'',
} }
const rootReducer = (state = globalState, action) => { const rootReducer = (state = globalState, action) => {
......
...@@ -18,6 +18,9 @@ import ActionType from '../redux/globalActionType'; ...@@ -18,6 +18,9 @@ import ActionType from '../redux/globalActionType';
import { CommonActions } from '@react-navigation/native'; import { CommonActions } from '@react-navigation/native';
import { Ionicons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons'; import { Ionicons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons';
import Axios from 'axios'; 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 { class Account extends React.Component {
constructor(props) { constructor(props) {
...@@ -30,14 +33,44 @@ class Account extends React.Component { ...@@ -30,14 +33,44 @@ class Account extends React.Component {
member_since: "", member_since: "",
account_number: "", account_number: "",
expire_date: "", expire_date: "",
premium: "" premium: "",
my_lat:0,
my_long:0
} }
} }
componentDidMount() { componentDidMount() {
this._getProfile(); this._getPermissions()
this.props.navigation }
console.log(" INI DATANYA " + this.props.set_card);
_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() { logout() {
...@@ -51,11 +84,14 @@ class Account extends React.Component { ...@@ -51,11 +84,14 @@ class Account extends React.Component {
_getProfile() { _getProfile() {
let params = { 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 => { 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 const dataCard = res.data
let email = dataCard.email let email = dataCard.email
let point = dataCard.kaspro_point let point = dataCard.kaspro_point
...@@ -66,10 +102,7 @@ class Account extends React.Component { ...@@ -66,10 +102,7 @@ class Account extends React.Component {
let premium = dataCard.kaspro_is_premium let premium = dataCard.kaspro_is_premium
let kaspro = dataCard.kaspro_account_number let kaspro = dataCard.kaspro_account_number
console.log("AKUN INI : " + premium);
console.log("INI CUYYYYYY: " + kaspro)
if (kaspro === "") { if (kaspro === "") {
console.log('Kaspro Kosong')
let cardProps = { let cardProps = {
set_card: false set_card: false
...@@ -78,7 +111,6 @@ class Account extends React.Component { ...@@ -78,7 +111,6 @@ class Account extends React.Component {
this.props.setCardactive(cardProps) this.props.setCardactive(cardProps)
} else { } else {
console.log('Kaspro Isi')
let cardProps = { let cardProps = {
set_card: true set_card: true
} }
...@@ -99,8 +131,6 @@ class Account extends React.Component { ...@@ -99,8 +131,6 @@ class Account extends React.Component {
premium: premium, premium: premium,
}) })
console.log(this.state.expire_date)
console.log('SET CARD NOW : ' + this.props.set_card)
}).catch(error => { }).catch(error => {
console.log('ini error ' + error) console.log('ini error ' + error)
}) })
...@@ -349,7 +379,6 @@ const styles = StyleSheet.create({ ...@@ -349,7 +379,6 @@ const styles = StyleSheet.create({
//subscribe //subscribe
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
console.log("INI STATEE NYA" + JSON.stringify(state));
return { return {
session_id: state.session_id, session_id: state.session_id,
set_card: state.set_card, set_card: state.set_card,
......
...@@ -9,13 +9,51 @@ class DeliveryAddrees extends React.Component { ...@@ -9,13 +9,51 @@ class DeliveryAddrees extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
data: [] data: [],
outlet_id:'',
grabamount:''
} }
} }
componentDidMount() { componentDidMount() {
this.getAddreess() 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 => { onChangeAddress = data => {
...@@ -64,7 +102,7 @@ class DeliveryAddrees extends React.Component { ...@@ -64,7 +102,7 @@ class DeliveryAddrees extends React.Component {
'Apakah anda akan memilih alamat untuk pengiriman ?', '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 } { cancelable: false }
) )
...@@ -184,6 +222,25 @@ const mapDispatchToProps = (dispacth) => { ...@@ -184,6 +222,25 @@ const mapDispatchToProps = (dispacth) => {
addressId: setDataAddress.addressId 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'; ...@@ -7,6 +7,10 @@ import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import _ from 'lodash'; 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 { class Home extends React.Component {
...@@ -25,9 +29,10 @@ class Home extends React.Component { ...@@ -25,9 +29,10 @@ class Home extends React.Component {
} }
componentDidMount() { componentDidMount() {
this._getPermissions()
this._renderCarousell() this._renderCarousell()
this._account() console.log(" ini yaaaaa"+ this.props.name_outlet)
} }
//fungsi untuk get current posisi //fungsi untuk get current posisi
...@@ -37,9 +42,39 @@ class Home extends React.Component { ...@@ -37,9 +42,39 @@ class Home extends React.Component {
this.state.search.clear(); 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() { _renderCarousell() {
Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/list/promotions-carousel').then(respon => { Axios.get('https://excelsocrm.ravintoladev.com/cms/v2/list/promotions-carousel').then(respon => {
// console.log(respon); // console.log(respon);
const dataCarousell = respon.data.contents; const dataCarousell = respon.data.contents;
// console.log(dataCarousell); // console.log(dataCarousell);
// console.log(dataCarousell); // console.log(dataCarousell);
...@@ -57,15 +92,30 @@ class Home extends React.Component { ...@@ -57,15 +92,30 @@ class Home extends React.Component {
_account() { _account() {
let params = { 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 => { 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 const dataCard = res.data
let point = dataCard.kaspro_point let point = dataCard.kaspro_point
let balance = dataCard.kaspro_balance let balance = dataCard.kaspro_balance
let expire = dataCard.expire_date let expire = dataCard.expire_date
let account_number = dataCard.kaspro_account_number 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({ this.setState({
point: point, point: point,
...@@ -139,7 +189,7 @@ class Home extends React.Component { ...@@ -139,7 +189,7 @@ class Home extends React.Component {
{i18n.t('orderInfo')} {i18n.t('orderInfo')}
</Text> </Text>
<Text style={{ textAlign: "center", fontSize: 12, top: 5 }}> <Text style={{ textAlign: "center", fontSize: 12, top: 5 }}>
Excelso Senayan City {this.props.name_outlet}
</Text> </Text>
<TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={this.onPress}> <TouchableOpacity style={styles.submitOrder} activeOpacity={.5} onPress={this.onPress}>
<Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text> <Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>{i18n.t('orderNow')}</Text>
...@@ -260,11 +310,26 @@ const styles = StyleSheet.create({ ...@@ -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) => { const mapStateToProps = (state) => {
return { return {
// login // login
email: state.email, email: state.email,
outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
session_id: state.session_id, session_id: state.session_id,
password: state.password, password: state.password,
fb_token: state.fb_token, fb_token: state.fb_token,
...@@ -281,4 +346,4 @@ const mapStateToProps = (state) => { ...@@ -281,4 +346,4 @@ const mapStateToProps = (state) => {
export default connect(mapStateToProps)(Home) export default connect(mapStateToProps,mapDispatchToProps)(Home)
\ No newline at end of file \ No newline at end of file
...@@ -22,17 +22,19 @@ class MenuSelection extends React.Component { ...@@ -22,17 +22,19 @@ class MenuSelection extends React.Component {
} }
} }
componentDidMount() { componentDidMount() {
console.log("INI YA :" + this.props.outlet_id)
this.getMenuList() this.getMenuList()
} }
getMenuList() { getMenuList() {
let params = { let params = {
outlet_id: this.props.outlet_id
outlet_id: "dec1abbb-95d0-46ae-a6cd-2bf306590f15"
} }
console.log("INI YA " + params)
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/menu/get_list', params).then(res => {
let data = res.data.data let data = res.data.data
console.log("INI DATANYA" + JSON.stringify(data))
this.setState({ this.setState({
listCategory: data.category, listCategory: data.category,
listMenu: data.menu listMenu: data.menu
......
...@@ -72,7 +72,7 @@ class PickupName extends React.Component { ...@@ -72,7 +72,7 @@ class PickupName extends React.Component {
} }
this.props.setChangeOutletProps(OutletChange); this.props.setChangeOutletProps(OutletChange);
this.props.navigation.navigate("Menu Select") this.props.navigation.navigate('Home', { screen: 'MENU' })
} }
getOutlet() { getOutlet() {
......
...@@ -11,6 +11,9 @@ import ItemShoping from './ItemShopingCart'; ...@@ -11,6 +11,9 @@ import ItemShoping from './ItemShopingCart';
import Axios from 'axios' import Axios from 'axios'
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import { YellowBox } from 'react-native'; 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']); YellowBox.ignoreWarnings(['VirtualizedLists should never be nested']);
class ShoppingCart extends React.Component { class ShoppingCart extends React.Component {
...@@ -34,12 +37,16 @@ class ShoppingCart extends React.Component { ...@@ -34,12 +37,16 @@ class ShoppingCart extends React.Component {
grabpickup: '', grabpickup: '',
grabdropoff: '', grabdropoff: '',
grabdestination: '', grabdestination: '',
my_lat:0,
my_long:0
// dummyBalance : 155000, // dummyBalance : 155000,
// dummyPoint : 20000 // dummyPoint : 20000
} }
} }
checkChangeTrans(val) { checkChangeTrans(val) {
console.log('hai lg di sini') console.log('hai lg di sini')
console.log(val) console.log(val)
...@@ -95,9 +102,9 @@ class ShoppingCart extends React.Component { ...@@ -95,9 +102,9 @@ class ShoppingCart extends React.Component {
image: item.image, image: item.image,
description: item.description, description: item.description,
quantity: item.quantity quantity: item.quantity
} }
this.props.removeFromChart(order_item) this.props.removeFromChart(order_item)
// this.props.navigation.navigate('Home', { // this.props.navigation.navigate('Home', {
// screen: 'Menu Select', // screen: 'Menu Select',
...@@ -187,10 +194,41 @@ class ShoppingCart extends React.Component { ...@@ -187,10 +194,41 @@ class ShoppingCart extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.getBalance() this._getPermissions()
this.getRate() 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() { getRate() {
...@@ -233,7 +271,10 @@ class ShoppingCart extends React.Component { ...@@ -233,7 +271,10 @@ class ShoppingCart extends React.Component {
getBalance() { getBalance() {
let params = { 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 => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/member/get_profile', params).then(res => {
...@@ -266,13 +307,13 @@ class ShoppingCart extends React.Component { ...@@ -266,13 +307,13 @@ class ShoppingCart extends React.Component {
{ {
this.state.isDelivery == true ? ( this.state.isDelivery == true ? (
<Card style={{ margin: 5, padding: 10 }}> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Ambil pesanan kamu di</Text> <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> </Card>
) : ( ) : (
<Card style={{ margin: 5, padding: 10 }}> <Card style={{ margin: 5, padding: 10 }}>
<Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text> <Text style={{ textAlign: 'center' }}> Pesanan kamu dikirim ke</Text>
<Text style={{ textAlign: 'center' }}>{this.props.address}</Text> <Text style={{ textAlign: 'center' }}>{this.props.address}</Text>
</Card> </Card>
) )
...@@ -500,7 +541,6 @@ class ShoppingCart extends React.Component { ...@@ -500,7 +541,6 @@ class ShoppingCart extends React.Component {
} }
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
...@@ -679,6 +719,7 @@ const mapStateToProps = (state) => { ...@@ -679,6 +719,7 @@ const mapStateToProps = (state) => {
return { return {
session_id: state.session_id, session_id: state.session_id,
outlet_id: state.outlet_id, outlet_id: state.outlet_id,
name_outlet: state.name_outlet,
order_quantity: state.order_quantity, order_quantity: state.order_quantity,
order_total: state.order_total, order_total: state.order_total,
order_item: state.order_item, 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