Commit 6be89811 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

order detail

parent f5cf5b1e
...@@ -32,7 +32,8 @@ const ActionType = { ...@@ -32,7 +32,8 @@ const ActionType = {
SET_TRANS_TYPE : 'SET_TRANS_TYPE', SET_TRANS_TYPE : 'SET_TRANS_TYPE',
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',
SET_TRANS_ID:'SET_TRANS_ID'
} }
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,
......
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'})}/>,
})}/>
</> </>
) )
......
...@@ -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,
}
}) })
} }
} }
......
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
} }
} }
......
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