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

order detail

parent f5cf5b1e
......@@ -32,7 +32,8 @@ const ActionType = {
SET_TRANS_TYPE : 'SET_TRANS_TYPE',
SET_RECALCULATE: 'SET_RECALCULATE',
SET_ORDER_FINISH: 'SET_ORDER_FINISH',
UPDATE_MENU: 'UPDATE_MENU'
UPDATE_MENU: 'UPDATE_MENU',
SET_TRANS_ID:'SET_TRANS_ID'
}
export default ActionType;
\ No newline at end of file
......@@ -75,6 +75,8 @@ const globalState = {
balanceUsed:'',
pointused:'',
trans_id:''
}
......@@ -265,6 +267,12 @@ const rootReducer = (state = globalState, action) => {
addressId:action.data.addressId
}
}
case ActionType.SET_TRANS_ID: {
return {
...state,
trans_id: action.data.trans_id
}
}
case ActionType.SET_LOGOUT: {
return {
...state,
......
import * as React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { createStackNavigator, HeaderBackButton } from '@react-navigation/stack';
import { connect } from 'react-redux';
import { View, Text } from 'react-native';
import ActionType from '../redux/globalActionType';
......@@ -125,7 +125,6 @@ class Auth extends React.Component {
}
render() {
return (
<Stack.Navigator>
{
......@@ -170,7 +169,8 @@ class Auth extends React.Component {
<Stack.Screen name="Card Info" component={CardInfo} />
<Stack.Screen name="Shopping Cart" component={ShoppingCart} />
<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 {
console.log('BOOK : ' + JSON.stringify(params))
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/booking', params).then(res => {
let data_order = res.data.data.id
this.setState({
spinner: false,
})
let transIdProps = {
trans_id : data_order
}
this.props.setTransId(transIdProps);
Alert.alert(
"Berhasil",
"Transaksi sudah berhasil, terimakasih sudah menggunakan excelso untuk ngopi",
......@@ -85,10 +90,7 @@ class MenuConfirmation extends React.Component {
orderSuccess = () => {
this.props.setOrderFinish()
this.props.navigation.navigate('Home', {
screen: 'ORDER',
params: { user: 'janei' },
});
this.props.navigation.navigate('Order Detail');
// this.props.navigation.reset({
// routes: [{ name: 'Home' }]
// })
......@@ -236,6 +238,12 @@ const mapDispatchToProps = (dispacth) => {
return {
setOrderFinish: () => dispacth({
type: ActionType.SET_ORDER_FINISH
}),
setTransId: (transIdProps) => dispacth({
type: ActionType.SET_TRANS_ID,
data: {
trans_id: transIdProps.trans_id,
}
})
}
}
......
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 { connect } from 'react-redux';
import Axios from 'axios';
import session from '../function/session';
class OrderDetail extends React.Component {
constructor(props) {
super(props)
this.handleBackButtonClick = this.handleBackButtonClick.bind(this)
this.state = {
trans_type_display:'',
outlet:'',
......@@ -15,20 +17,34 @@ class OrderDetail extends React.Component {
trans_status_display:'',
transaction_detail:[],
}
}
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
this.getDetailTrans()
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick() {
this.props.navigation.navigate('Home',{screen:'ORDER'});
return true;
}
getDetailTrans() {
let params = {
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 => {
let data = res.data
// console.log("INI OUTLET "+ data.outlet)
......@@ -43,8 +59,15 @@ class OrderDetail extends React.Component {
})
}).catch(error => {
let response = error.response.data;
const { navigation } = this.props
let response = error.response.data
session(response, navigation)
Alert.alert(response.msg);
this.setState({
indicator: false,
})
// let response = error.response.data;
// Alert.alert(response.msg);
})
}
......@@ -110,6 +133,7 @@ const mapStateToProps = (state) => {
return {
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