Commit 4aff7651 authored by Afid's avatar Afid

Merge branch 'master' of ssh://repo.cs.co.id:2222/wahyu/bahanoprek

# Conflicts:
#	redux/globalActionType.js
#	redux/globalReducer.js
#	view/Item.js
#	view/ItemShopingCart.js
parents e1aa0de1 1b3ca2f8
{ {
"expo": { "expo": {
"name": "Excelso_update v1_malam", "name": "Excelso_update v1.06062020",
"slug": "excelso-pro", "slug": "excelso-pro",
"privacy": "public", "privacy": "public",
"sdkVersion": "36.0.0", "sdkVersion": "36.0.0",
......
...@@ -33,7 +33,10 @@ const ActionType = { ...@@ -33,7 +33,10 @@ const ActionType = {
SET_RECALCULATE: 'SET_RECALCULATE', SET_RECALCULATE: 'SET_RECALCULATE',
SET_ORDER_FINISH: 'SET_ORDER_FINISH', SET_ORDER_FINISH: 'SET_ORDER_FINISH',
UPDATE_MENU: 'UPDATE_MENU', UPDATE_MENU: 'UPDATE_MENU',
CHANGE_QUANTITY: 'CHANGE_QUANTITY' CHANGE_QUANTITY: 'CHANGE_QUANTITY',
SET_TRANS_ID:'SET_TRANS_ID',
CHANGE_TO_CHART:'CHANGE_TO_CHART'
} }
export default ActionType; export default ActionType;
\ No newline at end of file
...@@ -76,6 +76,8 @@ const globalState = { ...@@ -76,6 +76,8 @@ const globalState = {
balanceUsed:'', balanceUsed:'',
pointused:'', pointused:'',
trans_id:''
} }
const rootReducer = (state = globalState, action) => { const rootReducer = (state = globalState, action) => {
...@@ -265,6 +267,12 @@ const rootReducer = (state = globalState, action) => { ...@@ -265,6 +267,12 @@ const rootReducer = (state = globalState, action) => {
addressId:action.data.addressId addressId:action.data.addressId
} }
} }
case ActionType.SET_TRANS_ID: {
return {
...state,
trans_id: action.data.trans_id
}
}
case ActionType.SET_LOGOUT: { case ActionType.SET_LOGOUT: {
return { return {
...state, ...state,
...@@ -332,6 +340,64 @@ const rootReducer = (state = globalState, action) => { ...@@ -332,6 +340,64 @@ const rootReducer = (state = globalState, action) => {
} }
} }
case ActionType.CHANGE_TO_CHART: {
let addedItem = action.data.item
let is_exist = state.order_item.find(item => addedItem.id == item.id)
let order_item = []
if (is_exist) {
// update
updated_data = []
for (let i = 0; i < state.order_item.length; i++) {
const old_data = state.order_item[i];
const data = old_data;
if (old_data.id == addedItem.id) {
update = old_data
if (update.quantity == NaN) {
update.quantity = 1
}
console.log('Update : ' + JSON.stringify(update))
data = { ...old_data, ...update }
}
updated_data.push(data)
}
order_item = updated_data
} else {
// addcd ..
order_item = [...state.order_item]
}
let quantity = state.order_quantity
let menu_item = []
for (let i = 0; i < state.menu_item.length; i++) {
const row = state.menu_item[i];
if (row.id == addedItem.id) {
let is_exist = order_item.find(item => addedItem.id == item.id)
if (is_exist) {
row.qty = is_exist.quantity
}
}
menu_item.push(row)
}
return {
...state,
menu_item: menu_item,
order_item: order_item,
order_quantity: quantity,
}
}
case ActionType.REDUCE_QUANTITY_ITEM: { case ActionType.REDUCE_QUANTITY_ITEM: {
let addedItem = action.data.item let addedItem = action.data.item
......
import * as React from 'react'; import * as React from 'react';
import { createStackNavigator } from '@react-navigation/stack'; import { createStackNavigator, HeaderBackButton } from '@react-navigation/stack';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { View, Text } from 'react-native'; import { View, Text } from 'react-native';
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
...@@ -125,7 +125,6 @@ class Auth extends React.Component { ...@@ -125,7 +125,6 @@ class Auth extends React.Component {
} }
render() { render() {
return ( return (
<Stack.Navigator> <Stack.Navigator>
{ {
...@@ -170,7 +169,8 @@ class Auth extends React.Component { ...@@ -170,7 +169,8 @@ class Auth extends React.Component {
<Stack.Screen name="Card Info" component={CardInfo} /> <Stack.Screen name="Card Info" component={CardInfo} />
<Stack.Screen name="Shopping Cart" component={ShoppingCart} /> <Stack.Screen name="Shopping Cart" component={ShoppingCart} />
<Stack.Screen name="Order History" component={OrderHistory} /> <Stack.Screen name="Order History" component={OrderHistory} />
<Stack.Screen name="Order Detail" component={OrderDetail} /> <Stack.Screen name="Order Detail" component={OrderDetail} options={({ navigation, route }) => ({ headerLeft: props => <HeaderBackButton {...props} onPress={()=>navigation.navigate('Home',{screen:'ORDER'})}/>,
})}/>
</> </>
) )
......
...@@ -284,7 +284,7 @@ class Home extends React.Component { ...@@ -284,7 +284,7 @@ class Home extends React.Component {
<TouchableOpacity style={styles.submitUpgradePemium} activeOpacity={.5} onPress={this.onPress}> <TouchableOpacity style={styles.submitUpgradePemium} activeOpacity={.5} onPress={this.onPress}>
<Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>TOP BALANCE </Text> <Text style={{ textAlign: 'center', bottom: 5, color: 'white' }}>TOP BALANCE </Text>
</TouchableOpacity> </TouchableOpacity>
<Text>APP.V2.APRIL</Text> <Text>UPDATE SORE </Text>
<View style={{ height: 60 }}></View> <View style={{ height: 60 }}></View>
</View> </View>
</View> </View>
......
...@@ -6,46 +6,44 @@ import ActionType from '../redux/globalActionType'; ...@@ -6,46 +6,44 @@ import ActionType from '../redux/globalActionType';
class Item extends React.Component { class Item extends React.Component {
handleChangeQuantity = (item, quantity) => { handleChangeQuantity = (item, quantity) => {
this.props.changeQuantity({item: item, quantity: quantity}) this.props.changeQuantity({ item: item, quantity: quantity })
} }
render() { render() {
const { item } = this.props const { item } = this.props
// console.log("ini id itemnya "+item.id) // console.log("ini id itemnya "+item.id)
return ( return (
<View style={{ flex: 1, margin: 10 }} key={item.id} ref={this.props._scrollView}> <View style={{ flex: 1, margin: 10 }} key={item.id} ref={this.props._scrollView}>
<ScrollView ref={view => this._scrollView = view}> <ScrollView ref={view => this._scrollView = view}>
{item.code == 'CATEGORY' ? ( {item.code == 'CATEGORY' ? (
<Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text> <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text>
): ( ) : (
<View style={{ flexDirection: 'row' }}> <View style={{ flexDirection: 'row' }}>
<View > <View >
<Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 5, top: 5 }}></Image> <Image source={{ uri: item.image }} style={{ height: 100, width: 100, borderRadius: 5, top: 5 }}></Image>
</View> </View>
<View > <View >
<Text style={{ fontSize: 20, margin: 5, marginRight: 10, fontWeight: 'bold' }}>{item.name}</Text> <Text style={{ fontSize: 20, margin: 5, marginRight: 10, fontWeight: 'bold' }}>{item.name}</Text>
<Text style={{ fontSize: 15, margin: 5, marginRight: 10 }}>Rp. {item.price}</Text> <Text style={{ fontSize: 15, margin: 5, marginRight: 10 }}>Rp. {item.price}</Text>
<View style={{ flexDirection: 'row', flex: 1 }}> <View style={{ flexDirection: 'row', flex: 1 }}>
<View style={styles.shadowEdit}></View> <View style={styles.shadowEdit}></View>
<View style={styles.shadowAdd}> <View style={styles.shadowAdd}>
<TouchableOpacity onPress={() => this.props.handleMin()}> <TouchableOpacity onPress={() => this.props.handleMin()}>
<Text style={{ fontSize: 20, margin: 2 }}> - </Text> <Text style={{ fontSize: 20, margin: 2 }}> - </Text>
</TouchableOpacity> </TouchableOpacity>
<TextInput <TextInput
style={{ height: 25, padding: 2, textAlign: 'center', margin: 2 }} style={{ height: 25, padding: 2, textAlign: 'center', margin: 2 }}
keyboardType={'numeric'} keyboardType={'numeric'}
onChangeText={(qty) => this.handleChangeQuantity(item, qty)}>{item.qty}</TextInput> onChangeText={(qty) => this.handleChangeQuantity(item, qty)}>{item.qty}</TextInput>
<TouchableOpacity onPress={() => this.props.handleAdd()}> <TouchableOpacity onPress={() => this.props.handleAdd()}>
<Text style={{ fontSize: 20, margin: 2 }}> + </Text> <Text style={{ fontSize: 20, margin: 2 }}> + </Text>
</TouchableOpacity> </TouchableOpacity>
</View>
</View>
</View> </View>
</View> </View>
</View> )}
</View>
)}
</ScrollView> </ScrollView>
</View> </View>
) )
...@@ -104,6 +102,23 @@ const styles = StyleSheet.create({ ...@@ -104,6 +102,23 @@ const styles = StyleSheet.create({
} }
}) })
const mapDispatchToProps = (dispacth) => {
return {
setChangeQuantity: (item) => dispacth({
type: ActionType.CHANGE_TO_CHART,
data: {
item: item
}
}),
changeQuantity: (params) => dispacth({
type: ActionType.CHANGE_QUANTITY,
data: {
item: params.item,
new_quantity: params.quantity
}
}),
}
}
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
// console.log(state) // console.log(state)
return { return {
...@@ -115,16 +130,4 @@ const mapStateToProps = (state) => { ...@@ -115,16 +130,4 @@ const mapStateToProps = (state) => {
} }
} }
const mapDispatchToProps = (dispacth) => {
return {
changeQuantity: (params) => dispacth({
type: ActionType.CHANGE_QUANTITY,
data: {
item: params.item,
new_quantity: params.quantity
}
}),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Item) export default connect(mapStateToProps, mapDispatchToProps)(Item)
...@@ -10,11 +10,10 @@ class ItemShoping extends React.Component { ...@@ -10,11 +10,10 @@ class ItemShoping extends React.Component {
console.log('new quantity : ' + quantity) console.log('new quantity : ' + quantity)
this.props.changeQuantity({item: item, quantity: quantity}) this.props.changeQuantity({item: item, quantity: quantity})
} }
render() { render() {
const { item } = this.props const { item } = this.props
return ( return (
<View style={{ flex: 1, margin: 10 }} key={item.id}> <View style={{ flex: 1, margin: 10 }} key={item.id}>
{/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text> */} {/* <Text style={{ fontSize: 20, color: '#c9af6d' }}>{item.name}</Text> */}
<View style={{ flexDirection: 'row' }}> <View style={{ flexDirection: 'row' }}>
......
...@@ -59,10 +59,15 @@ class MenuConfirmation extends React.Component { ...@@ -59,10 +59,15 @@ class MenuConfirmation extends React.Component {
console.log('BOOK : ' + JSON.stringify(params)) console.log('BOOK : ' + JSON.stringify(params))
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 => {
let data_order = res.data.data.id
this.setState({ this.setState({
spinner: false, spinner: false,
}) })
let transIdProps = {
trans_id : data_order
}
this.props.setTransId(transIdProps);
Alert.alert( Alert.alert(
"Berhasil", "Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi", "Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
...@@ -85,10 +90,7 @@ class MenuConfirmation extends React.Component { ...@@ -85,10 +90,7 @@ class MenuConfirmation extends React.Component {
orderSuccess = () => { orderSuccess = () => {
this.props.setOrderFinish() this.props.setOrderFinish()
this.props.navigation.navigate('Home', { this.props.navigation.navigate('Order Detail');
screen: 'ORDER',
params: { user: 'janei' },
});
// this.props.navigation.reset({ // this.props.navigation.reset({
// routes: [{ name: 'Home' }] // routes: [{ name: 'Home' }]
// }) // })
...@@ -236,6 +238,12 @@ const mapDispatchToProps = (dispacth) => { ...@@ -236,6 +238,12 @@ const mapDispatchToProps = (dispacth) => {
return { return {
setOrderFinish: () => dispacth({ setOrderFinish: () => dispacth({
type: ActionType.SET_ORDER_FINISH type: ActionType.SET_ORDER_FINISH
}),
setTransId: (transIdProps) => dispacth({
type: ActionType.SET_TRANS_ID,
data: {
trans_id: transIdProps.trans_id,
}
}) })
} }
} }
......
...@@ -24,6 +24,8 @@ class MenuSelection extends React.Component { ...@@ -24,6 +24,8 @@ class MenuSelection extends React.Component {
order_list: [], order_list: [],
list_cart: [], list_cart: [],
indicator: true, indicator: true,
my_lat: 0,
my_long: 0
} }
} }
...@@ -36,17 +38,16 @@ class MenuSelection extends React.Component { ...@@ -36,17 +38,16 @@ class MenuSelection extends React.Component {
indicator: true indicator: true
}) })
this._getPermissions() this._getPermissions()
this.getMenuList()
} }
// console.log("INI OUTLET : "+ this.props.outlet_id) // console.log("INI OUTLET : "+ this.props.outlet_id)
this._unsubscribe = this.props.navigation.addListener('focus', () => { this._unsubscribe = this.props.navigation.addListener('focus', () => {
if (this.props.outlet_id != '') { if (this.props.outlet_id != '') {
this.getMenuList()
} else {
this.setState({ this.setState({
indicator:true indicator: true
}) })
this._getPermissions() this._getPermissions()
this.getMenuList()
} }
}); });
} }
...@@ -166,9 +167,9 @@ class MenuSelection extends React.Component { ...@@ -166,9 +167,9 @@ class MenuSelection extends React.Component {
}) })
}).catch(error => { }).catch(error => {
const {navigation} = this.props const { navigation } = this.props
let response = error.response.data let response = error.response.data
session(response,navigation) session(response, navigation)
Alert.alert(response.msg); Alert.alert(response.msg);
}) })
...@@ -300,18 +301,18 @@ class MenuSelection extends React.Component { ...@@ -300,18 +301,18 @@ class MenuSelection extends React.Component {
)} )}
</View> </View>
<View style={styles.shadow}> <View style={styles.shadow}>
{ {
this.state.indicator == true ? (<ActivityIndicator style={{ top: 10 }} size="large" color="#c9af6d" />):( this.state.indicator == true ? (<ActivityIndicator style={{ top: 10 }} size="large" color="#c9af6d" />) : (
<View style={{ flexDirection: 'row', }}> <View style={{ flexDirection: 'row', }}>
<Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.props.order_quantity} </Text> <Text style={{ fontSize: 12, margin: 10 }}> Price Estimation / Item {this.props.order_quantity} </Text>
<Text style={{ fontSize: 12, margin: 10 }}> Ongkir {this.props.grabamount} </Text> <Text style={{ fontSize: 12, margin: 10 }}> Ongkir {this.props.grabamount} </Text>
<Text style={{ fontSize: 20, margin: 10, marginBottom: 10 }}> Rp. {this.props.order_total}</Text> <Text style={{ fontSize: 20, margin: 10, marginBottom: 10 }}> Rp. {this.props.order_total}</Text>
</View> </View>
) )
} }
<View> <View>
<Button title="VIEW CART" onPress={() => this.props.navigation.navigate('Shopping Cart')}></Button> <Button title="VIEW CART" onPress={() => this.props.navigation.navigate('Shopping Cart')}></Button>
</View> </View>
...@@ -390,26 +391,3 @@ const mapDispatchToProps = (dispacth) => { ...@@ -390,26 +391,3 @@ const mapDispatchToProps = (dispacth) => {
} }
export default connect(mapStateToProps, mapDispatchToProps)(MenuSelection) export default connect(mapStateToProps, mapDispatchToProps)(MenuSelection)
import React from 'react'; import React from 'react';
import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity } from 'react-native'; import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity,BackHandler } from 'react-native';
import { Card } from 'react-native-shadow-cards' import { Card } from 'react-native-shadow-cards'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import session from '../function/session';
class OrderDetail extends React.Component { class OrderDetail extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.handleBackButtonClick = this.handleBackButtonClick.bind(this)
this.state = { this.state = {
trans_type_display:'', trans_type_display:'',
outlet:'', outlet:'',
...@@ -15,20 +17,34 @@ class OrderDetail extends React.Component { ...@@ -15,20 +17,34 @@ class OrderDetail extends React.Component {
trans_status_display:'', trans_status_display:'',
transaction_detail:[], transaction_detail:[],
} }
} }
componentDidMount() { componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
this.getDetailTrans() this.getDetailTrans()
} }
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick() {
this.props.navigation.navigate('Home',{screen:'ORDER'});
return true;
}
getDetailTrans() { getDetailTrans() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans transaction_id: this.props.trans_id
} }
console.log("PARAMETER : " + JSON.stringify(params))
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/detail', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/detail', params).then(res => {
let data = res.data let data = res.data
// console.log("INI OUTLET "+ data.outlet) // console.log("INI OUTLET "+ data.outlet)
...@@ -43,8 +59,15 @@ class OrderDetail extends React.Component { ...@@ -43,8 +59,15 @@ class OrderDetail extends React.Component {
}) })
}).catch(error => { }).catch(error => {
let response = error.response.data; const { navigation } = this.props
let response = error.response.data
session(response, navigation)
Alert.alert(response.msg); Alert.alert(response.msg);
this.setState({
indicator: false,
})
// let response = error.response.data;
// Alert.alert(response.msg);
}) })
} }
...@@ -110,6 +133,7 @@ const mapStateToProps = (state) => { ...@@ -110,6 +133,7 @@ const mapStateToProps = (state) => {
return { return {
session_id: state.session_id, session_id: state.session_id,
trans_id : state.trans_id
} }
} }
......
...@@ -107,6 +107,11 @@ class ShoppingCart extends React.Component { ...@@ -107,6 +107,11 @@ class ShoppingCart extends React.Component {
} }
} }
onChange(params){
console.log(params);
}
handleMin(item, index) { handleMin(item, index) {
this.setState({ this.setState({
checkedBalance: false, checkedBalance: false,
...@@ -277,6 +282,9 @@ class ShoppingCart extends React.Component { ...@@ -277,6 +282,9 @@ class ShoppingCart extends React.Component {
} }
getRate() { getRate() {
let params = { let params = {
...@@ -323,6 +331,10 @@ class ShoppingCart extends React.Component { ...@@ -323,6 +331,10 @@ class ShoppingCart extends React.Component {
} }
onChange(){
}
checkOut() { checkOut() {
if (this.props.order_item.length == 0){ if (this.props.order_item.length == 0){
Alert.alert('Error', 'Please choose your order first') Alert.alert('Error', 'Please choose your order first')
...@@ -399,6 +411,7 @@ class ShoppingCart extends React.Component { ...@@ -399,6 +411,7 @@ class ShoppingCart extends React.Component {
item={item} item={item}
handleAdd={() => this.handleAdd(item, index)} handleAdd={() => this.handleAdd(item, index)}
handleMin={() => this.handleMin(item, index)} handleMin={() => this.handleMin(item, index)}
onChange={()=> this.onChange(item,index)}
/> />
)} )}
keyExtractor={item => item.id} keyExtractor={item => item.id}
......
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