Commit 696c03bf authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

ini ya

parent 2ef8194c
...@@ -106,7 +106,7 @@ function HomePage() { ...@@ -106,7 +106,7 @@ function HomePage() {
<Tab.Screen name="HOME" component={Home} /> <Tab.Screen name="HOME" component={Home} />
<Tab.Screen name="MENU" component={MenuSelection} /> <Tab.Screen name="MENU" component={MenuSelection} />
<Tab.Screen name="REWARDS" component={Rewards} /> <Tab.Screen name="REWARDS" component={Rewards} />
<Tab.Screen name="ORDER" component={OrderHistory} /> <Tab.Screen name="ORDER" component={TransactionHistory} />
<Tab.Screen name="OUTLETS" component={Outlets} /> <Tab.Screen name="OUTLETS" component={Outlets} />
<Tab.Screen name="ACCOUNT" component={Account} /> <Tab.Screen name="ACCOUNT" component={Account} />
</Tab.Navigator> </Tab.Navigator>
......
...@@ -17,37 +17,7 @@ class DeliveryAddrees extends React.Component { ...@@ -17,37 +17,7 @@ class DeliveryAddrees extends React.Component {
componentDidMount() { componentDidMount() {
this.getAddreess() this.getAddreess()
this.getRate() console.log("INI ADDRESS ID : "+ this.props.addressId)
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);
}).catch(error => {
console.log('ini error ' + error)
})
} }
onChangeAddress = data => { onChangeAddress = data => {
...@@ -69,12 +39,9 @@ class DeliveryAddrees extends React.Component { ...@@ -69,12 +39,9 @@ class DeliveryAddrees extends React.Component {
address.push(element) address.push(element)
} }
this.setState({ this.setState({
data: address data: address
}) })
console.log(this.state.data[0].id)
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
Alert.alert( Alert.alert(
...@@ -84,16 +51,53 @@ class DeliveryAddrees extends React.Component { ...@@ -84,16 +51,53 @@ class DeliveryAddrees extends React.Component {
}) })
} }
getRate() {
let params = {
session_id: this.props.session_id,
address_id: this.props.addressId,
}
console.log("INI PRAMETER NYA : " + JSON.stringify(params))
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => {
this.setState({
grabamount: res.data.data.amount,
grabdestination: res.data.data.outlet_name,
})
let setGrabProps = {
grabdestination: this.state.grabdestination,
grabamount: this.state.grabamount,
}
this.props.setGrab(setGrabProps);
console.log("INI SUKSES RESPONNYA ")
let setOrdersProps = {
balanceUsed: this.state.balanceused,
pointused: this.state.pointsused,
}
this.props.setOrder(setOrdersProps);
}).catch(error => {
console.log('ini error ' + error)
})
}
addAdreess() { addAdreess() {
this.props.navigation.navigate('Address Detail', { 'data': 'sample', onChangeAddress: this.onChangeAddress }) this.props.navigation.navigate('Address Detail', { 'data': 'sample', onChangeAddress: this.onChangeAddress })
} }
onSave(address) { onSave(address,id) {
let setDataAddress = { let setDataAddress = {
address : address, address : address,
addressId : this.state.data[0].id addressId :id
} }
this.props.setAddress(setDataAddress); this.props.setAddress(setDataAddress);
...@@ -102,7 +106,7 @@ class DeliveryAddrees extends React.Component { ...@@ -102,7 +106,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.getRate() },
], ],
{ cancelable: false } { cancelable: false }
) )
...@@ -114,8 +118,9 @@ class DeliveryAddrees extends React.Component { ...@@ -114,8 +118,9 @@ class DeliveryAddrees extends React.Component {
renderItem = ({item})=>{ renderItem = ({item})=>{
return ( return (
<View style={styles.list_addrees}> <View style={styles.list_addrees}>
<TouchableOpacity onPress={()=> this.onSave(item.address)}> <TouchableOpacity onPress={()=> this.onSave(item.address,item.id)}>
<View style={{ margin: 5, }}> <View style={{ margin: 5, }}>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.id}</Text>
<Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text> <Text style={{ fontWeight: 'bold', fontSize: 20 }}>{item.name}</Text>
</View> </View>
<Text style={{ margin: 5 }}> <Text style={{ margin: 5 }}>
...@@ -197,7 +202,7 @@ const styles = StyleSheet.create({ ...@@ -197,7 +202,7 @@ const styles = StyleSheet.create({
}) })
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
console.log("INI STATE : "+ JSON.stringify(state))
return { return {
session_id: state.session_id, session_id: state.session_id,
...@@ -217,15 +222,6 @@ const mapDispatchToProps = (dispacth) => { ...@@ -217,15 +222,6 @@ 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({ setGrab: (setGrabProps) => dispacth({
type: ActionType.SET_GRAB, type: ActionType.SET_GRAB,
......
...@@ -37,20 +37,24 @@ class MenuConfirmation extends React.Component { ...@@ -37,20 +37,24 @@ class MenuConfirmation extends React.Component {
order_item: this.props.order_item, order_item: this.props.order_item,
delivery_charge: this.props.grabamount, delivery_charge: this.props.grabamount,
voucher: [], voucher: [],
payment: { payment: {
balance: this.props.route.params.balanceUsed, balance: this.props.route.params.balanceUsed,
point: this.props.route.params.pointused point: this.props.route.params.pointused
} }
} }
console.log("INI PARAMETER UNTUK ORDER : " + JSON.stringify())
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => {
Alert.alert( 'Transaksi Anda Berhasil') Alert.alert( 'Transaksi Anda Berhasil')
this.props.navigation.navigate('Order History'); this.props.navigation.navigate('Order History');
let typeProps = { // let typeProps = {
type_pickup: false, // type_pickup: false,
} // }
this.props.setTypePickup(typeProps); // this.props.setTypePickup(typeProps);
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
...@@ -87,7 +91,7 @@ class MenuConfirmation extends React.Component { ...@@ -87,7 +91,7 @@ class MenuConfirmation extends React.Component {
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
// console.log('error') console.log('ini error ' + error)
Alert.alert(response.msg); Alert.alert(response.msg);
}) })
} }
...@@ -188,11 +192,11 @@ class MenuConfirmation extends React.Component { ...@@ -188,11 +192,11 @@ class MenuConfirmation extends React.Component {
</View> </View>
</View> </View>
<View style={{ margin: 10 }}> <View style={{ margin: 10 }}>
{this.props.type_pickup == true ? ( {/* {this.props.type_pickup == true ? (
<Button title='order' onPress={() => this.setPickup()}/> <Button title='order' onPress={() => this.setPickup()}/>
):( ):( */}
<Button title='order' onPress={() => this.setOrder()}/> <Button title='order' onPress={() => this.setOrder()}/>
)} {/* )} */}
</View> </View>
</ScrollView> </ScrollView>
......
...@@ -25,6 +25,7 @@ class MenuSelection extends React.Component { ...@@ -25,6 +25,7 @@ class MenuSelection extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.getMenuList() this.getMenuList()
console.log("INI OUTLET : "+ this.props.outlet_id)
} }
getMenuList() { getMenuList() {
......
...@@ -26,7 +26,7 @@ class OrderHistory extends React.Component { ...@@ -26,7 +26,7 @@ class OrderHistory extends React.Component {
} }
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/list', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/list', params).then(res => {
let data = res.data.data let data = res.data.data
// console.log(data) console.log(data)
this.setState({ this.setState({
order_list: data order_list: data
}) })
...@@ -46,9 +46,10 @@ class OrderHistory extends React.Component { ...@@ -46,9 +46,10 @@ class OrderHistory extends React.Component {
this.state.order_list.map((item, key) => ( this.state.order_list.map((item, key) => (
<View key={key}> <View key={key}>
<Card style={{ padding: 10, margin: 10, alignContent: 'center' }}> <Card style={{ padding: 10, margin: 10, alignContent: 'center' }}>
<Text>{item.outlet}</Text> <Text>OUTLET : {item.outlet}</Text>
<Text>{item.trans_date}</Text> <Text>TGL TRANSAKSI : {item.trans_date}</Text>
<Text>{item.trans_total}</Text> <Text>TOTAL : {item.trans_total}</Text>
<Text>STATUS : {item.trans_status}</Text>
</Card> </Card>
</View> </View>
......
import React from 'react'; import React from 'react';
import { View, Text, TextInput, StyleSheet, Button, TouchableOpacity, ScrollView, FlatList, Image, Alert } from 'react-native'; import { View, Text, TextInput, StyleSheet, Button, TouchableOpacity, ScrollView, FlatList, Image, Alert, ActivityIndicator } from 'react-native';
import { connect } from 'react-redux' import { connect } from 'react-redux'
// import { CheckBox } from 'react-native-elements'
import CheckBox from 'react-native-check-box' import CheckBox from 'react-native-check-box'
import { Card } from 'react-native-shadow-cards' import { Card } from 'react-native-shadow-cards'
import { Entypo, Ionicons, MaterialCommunityIcons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons' import { Entypo, Ionicons, MaterialCommunityIcons, MaterialIcons, AntDesign, FontAwesome } from '@expo/vector-icons'
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import CurrencyFormat from 'react-currency-format';
import ItemShoping from './ItemShopingCart'; 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 {
...@@ -38,7 +34,8 @@ class ShoppingCart extends React.Component { ...@@ -38,7 +34,8 @@ class ShoppingCart extends React.Component {
grabdropoff: '', grabdropoff: '',
grabdestination: '', grabdestination: '',
my_lat:0, my_lat:0,
my_long:0 my_long:0,
indicator:true,
// dummyBalance : 155000, // dummyBalance : 155000,
// dummyPoint : 20000 // dummyPoint : 20000
} }
...@@ -46,6 +43,14 @@ class ShoppingCart extends React.Component { ...@@ -46,6 +43,14 @@ class ShoppingCart extends React.Component {
componentDidMount() {
this.getRate()
this.getBalance()
console.log("INI REDUX PROPS BAGIAN ID : " + this.props.addressId)
console.log("INI REDUX PROPS BAGIAN ID : " + this.props.addressId)
}
checkChangeTrans(val) { checkChangeTrans(val) {
console.log('hai lg di sini') console.log('hai lg di sini')
...@@ -105,27 +110,8 @@ class ShoppingCart extends React.Component { ...@@ -105,27 +110,8 @@ class ShoppingCart extends React.Component {
} }
this.props.removeFromChart(order_item) this.props.removeFromChart(order_item)
// this.props.navigation.navigate('Home', {
// screen: 'Menu Select',
// });
} }
} }
// else if (is_xist.quantity == 0){
// Alert.alert("Apakah anda akan menghapus pesanan ?")
// const order_item = {
// id: item.id,
// name: item.name,
// price: item.price,
// note: item.note,
// image: item.image,
// description: item.description,
// quantity: item.quantity
// }
// this.props.removeFromChart(order_item)
// console.log(order_item)
// }
} }
} }
...@@ -192,53 +178,17 @@ class ShoppingCart extends React.Component { ...@@ -192,53 +178,17 @@ class ShoppingCart extends React.Component {
} }
} }
componentDidMount() {
this._getPermissions()
this.getRate()
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() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
address_id: this.props.addressId, address_id: this.props.addressId,
order_item: this.props.order_item
} }
console.log("INI PRAMETER NYA : " + JSON.stringify(params))
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/delivery/rate', params).then(res => { 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({ this.setState({
grabamount: res.data.data.amount, grabamount: res.data.data.amount,
...@@ -246,15 +196,14 @@ class ShoppingCart extends React.Component { ...@@ -246,15 +196,14 @@ class ShoppingCart extends React.Component {
}) })
let setGrabProps = { let setGrabProps = {
// grabtype: this.state.grabtype,
// grabpickup: this.state.grabpickup,
// grabdropoff: this.state.grabdropoff,
grabdestination: this.state.grabdestination, grabdestination: this.state.grabdestination,
grabamount: this.state.grabamount, grabamount: this.state.grabamount,
} }
this.props.setGrab(setGrabProps); this.props.setGrab(setGrabProps);
console.log("INI SUKSES RESPONNYA ")
let setOrdersProps = { let setOrdersProps = {
balanceUsed: this.state.balanceused, balanceUsed: this.state.balanceused,
pointused: this.state.pointsused, pointused: this.state.pointsused,
...@@ -268,24 +217,16 @@ class ShoppingCart extends React.Component { ...@@ -268,24 +217,16 @@ class ShoppingCart extends React.Component {
} }
checkOut(){ checkOut(){
this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused }) this.props.navigation.navigate('Confirm Your Order', { balanceUsed: this.state.balanceused, pointused: this.state.pointsused })
} }
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 => {
// console.log(res.data)
const { kaspro_balance, kaspro_point } = res.data const { kaspro_balance, kaspro_point } = res.data
// console.log(kaspro_balance,kaspro_point)
this.setState({ this.setState({
kasproBalance: kaspro_balance, kasproBalance: kaspro_balance,
kasproPoint: kaspro_point kasproPoint: kaspro_point
...@@ -311,16 +252,18 @@ class ShoppingCart extends React.Component { ...@@ -311,16 +252,18 @@ class ShoppingCart extends React.Component {
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
{ {
this.state.isDelivery == true ? ( this.state.isDelivery == true ? (
<TouchableOpacity > <TouchableOpacity onPress={()=>this.props.navigation.navigate("Pickup Name")}>
<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.addressId}</Text>
<Text style={{ textAlign: 'center' }}>{this.props.name_outlet}</Text> <Text style={{ textAlign: 'center' }}>{this.props.name_outlet}</Text>
</Card> </Card>
</TouchableOpacity> </TouchableOpacity>
) : ( ) : (
<TouchableOpacity> <TouchableOpacity onPress={()=>this.props.navigation.navigate("Delivery Address")}>
<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>
...@@ -358,6 +301,7 @@ class ShoppingCart extends React.Component { ...@@ -358,6 +301,7 @@ class ShoppingCart extends React.Component {
<Text>PAYMENT METHODS</Text> <Text>PAYMENT METHODS</Text>
</View> </View>
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
{ {
this.state.kasproBalance < this.props.order_total ? ( this.state.kasproBalance < this.props.order_total ? (
<Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}> <Card style={{ margin: 5, padding: 10, backgroundColor: 'gray' }}>
......
...@@ -26,14 +26,13 @@ class TransactionHistory extends React.Component { ...@@ -26,14 +26,13 @@ class TransactionHistory extends React.Component {
this.setState({ this.setState({
history_list: data history_list: data
}) })
// console.log(this.state.history_list)
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
Alert.alert(response.msg); Alert.alert(response.msg);
}) })
} }
render() { render() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
......
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