Commit b5240593 authored by Trisno's avatar Trisno

transaction history detail jadi satu sama order history detail

parent 404eb336
...@@ -72,10 +72,8 @@ class OrderHistory extends React.Component { ...@@ -72,10 +72,8 @@ class OrderHistory extends React.Component {
indicator: false, indicator: false,
}) })
}).catch(error => { }).catch(error => {
const { navigation } = this.props
let response = error.response.data let response = error.response.data
session(response, navigation) Alert.alert('', response.msg);
Alert.alert(response.msg);
this.setState({ this.setState({
indicator: false, indicator: false,
}) })
......
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, ActivityIndicator } 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';
...@@ -9,12 +9,26 @@ class TransactionHistory extends React.Component { ...@@ -9,12 +9,26 @@ class TransactionHistory extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
history_list: [] history_list: [],
indicator: true
} }
} }
componentDidMount() { componentDidMount() {
this.getTransactionHistory() this.getTransactionHistory()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true,
})
this.getTransactionHistory()
});
}
componentWillUnmount() {
this._unsubscribe();
} }
getTransactionHistory() { getTransactionHistory() {
...@@ -23,14 +37,43 @@ class TransactionHistory extends React.Component { ...@@ -23,14 +37,43 @@ class TransactionHistory extends React.Component {
} }
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/history', params).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/history', params).then(res => {
let data = res.data.transactions let data = res.data.transactions
// console.log('ini datanya loh : ' + JSON.stringify(data)) console.log(data)
data.map((item) => {
item.transactions.map((i) => {
if (i.trans_status_display == 'On Queue') {
i.trans_status_display = 'Queueing'
} else
if (i.trans_status_display == 'On Process') {
i.trans_status_display = 'Processing'
} else
if (i.trans_status_display == 'Ready to Pickup') {
i.trans_status_display = 'Ready for Pickup'
} else
if (i.trans_status_display == 'On Delivery') {
i.trans_status_display = 'Delivering'
} else
if (i.trans_status_display == 'On Completed') {
i.trans_status_display = 'Completed'
} else
if (i.trans_status_display == 'Cancelled') {
i.trans_status_display = 'Cancelled'
}
})
})
// console.log(data)
this.setState({ this.setState({
history_list: data history_list: data,
indicator: false
}) })
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
Alert.alert(response.msg); Alert.alert(response.msg);
this.setState({
indicator: false,
})
}) })
} }
...@@ -38,27 +81,27 @@ class TransactionHistory extends React.Component { ...@@ -38,27 +81,27 @@ class TransactionHistory extends React.Component {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ScrollView style={styles.body}> <ScrollView style={styles.body}>
{ {this.state.indicator == true ? (<ActivityIndicator style={{ justifyContent: "center" }} size="large" color="#c9af6d" />) :
this.state.history_list.length ? ( this.state.history_list.length ? (
this.state.history_list.map((item) => ( this.state.history_list.map((item) => (
item.transactions.map((i, k) => ( item.transactions.map((i, k) => (
<TouchableOpacity key={k} onPress={() => this.props.navigation.navigate('Transaction Detail', { idTrans: i.id })}> <TouchableOpacity key={k} onPress={() => this.props.navigation.navigate('Order Detail', { idTrans: i.id })}>
<View style={{ marginTop: 5 }} key={k}> <View style={{ marginTop: 5 }} key={k}>
<View style={{ flex: 2, height: 120, margin: 5, borderRadius: 5, borderWidth: 1, flexDirection: 'row' }}> <View style={{ flex: 2, height: 120, margin: 5, borderRadius: 5, borderWidth: 1, borderColor: '#838383', flexDirection: 'row' }}>
<View style={{ justifyContent: 'center', margin: 10 }}> <View style={{ flex: 1.1, justifyContent: 'center', margin: 10 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'grey', fontSize: 12, margin: 2 }}>{i.outlet}</Text> <Text style={{ fontFamily: 'Gotham-Black', color: 'grey', fontSize: 12, margin: 2 }}>{i.outlet}</Text>
<Text style={{ fontFamily: 'Gotham-Light', color: 'grey', fontSize: 12, margin: 2 }}>{moment(i.trans_time).format("DD MMMM YYYY, hh:mm A")}</Text> <Text style={{ fontFamily: 'Gotham-Light', color: 'grey', fontSize: 12, margin: 2 }}>{moment(i.trans_time).format("DD MMMM YYYY, hh:mm A")}</Text>
<Text style={{ fontFamily: 'Gotham-Black', color: '#c9af6d', fontSize: 12, margin: 2 }}>{i.trans_type_display}</Text> <Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 12, margin: 2 }}>{i.trans_type_display}</Text>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Transaction Detail', { idTrans: i.id })}> <TouchableOpacity onPress={() => this.props.navigation.navigate('Order Detail', { idTrans: i.id })}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center' }}> <View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginVertical: 5 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 12, textAlign: 'center', margin: 15 }}>Lihat Detail Transaksi</Text> <Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 12, textAlign: 'center', paddingHorizontal: 5 }}>Lihat Detail Pemesanan</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<View style={{ justifyContent: 'center', marginVertical: 5, marginLeft: 20, borderLeftWidth: 1, borderColor: 'grey' }}> <View style={{ flex: 0.9, justifyContent: 'center', alignItems: 'center', margin: 10, marginLeft: 15, borderLeftWidth: 1, borderColor: '#838383' }}>
<View style={{ margin: 30 }}> <View>
<Text style={{ fontFamily: 'Gotham-Black', color: '#c9af6d', fontSize: 12, margin: 2 }}>{i.trans_status_display}</Text> <Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 12 }}>{i.trans_status_display}</Text>
</View> </View>
</View> </View>
</View> </View>
......
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