Commit f1248101 authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo

account , outlet

parent 7b1339f6
......@@ -232,7 +232,7 @@ class AddreesDetail extends React.Component {
<View style={styles.field_detail_addrees}>
<Text style={{ fontFamily: 'Gotham-Black', marginLeft: 10, color: "#ccb46c", textAlign: 'center', fontSize: 18 }} >Detail</Text>
<Text style={{ fontFamily: 'Gotham-Black', color: "#ccb46c",textAlign:'center', fontSize: 18 }}>Detail</Text>
<TextInput style={{ height: 150, borderWidth: 1, padding: 5, flex: 1, margin: 10, borderRadius: 10, borderColor: 'grey', justifyContent: 'flex-start' }}
onChangeText={(description) => this.setState({ description })}
numberOfLines={10}
......
......@@ -3,6 +3,7 @@ import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity,
import { Card } from 'react-native-shadow-cards'
import { connect } from 'react-redux';
import Axios from 'axios';
import { Rating, AirbnbRating } from 'react-native-elements';
import session from '../function/session';
import moment from 'moment'
import NumberFormat from 'react-number-format';
......@@ -23,7 +24,9 @@ class OrderDetail extends React.Component {
detail_trans: '',
trans_status: '',
modalVisible: false,
reason: ''
reason: '',
is_reviewed: '',
review_rating: 0
}
......@@ -53,27 +56,37 @@ class OrderDetail extends React.Component {
})
}
handleOrderCancel() {
// console.log(this.state.reason)
let params = {
session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans,
reason: this.state.reason
}
// console.log(params)
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/cancel', params).then(res => {
let respon = res.data.status
Alert.alert(respon, 'Order was canceled')
this.props.navigation.navigate('Home', { screen: 'ORDER' });
}).catch(error => {
Alert.alert('Error', error.data.msg)
})
handleBack(){
this.setState({
modalVisible: false
})
}
handleOrderCancel() {
if (this.state.reason == '') {
Alert.alert('', 'Reason must be filled !' )
}else{
let params = {
session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans,
reason: this.state.reason
}
// console.log(params)
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/cancel', params).then(res => {
let respon = res.data.status
Alert.alert(respon, 'Order was canceled')
this.props.navigation.navigate('Home', { screen: 'ORDER' });
}).catch(error => {
let response = error.response.data;
Alert.alert('',response.msg);
})
this.setState({
modalVisible: false
})
}
}
getDetailTrans() {
let params = {
session_id: this.props.session_id,
......@@ -83,7 +96,7 @@ class OrderDetail extends React.Component {
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/transaction/detail', params).then(res => {
let data = res.data
// console.log('ini data' + JSON.stringify(data))
console.log("INI OUTLET "+ data.outlet)
console.log("INI OUTLET " + data.outlet)
// console.log("OUTLET-CODE" + data.outlet_code)
// console.log("TRANS-DISPLAY" + data.trans_type_display)
......@@ -93,45 +106,23 @@ class OrderDetail extends React.Component {
trans_status_display: data.trans_status_display,
transaction_detail: data.transaction_detail,
detail_trans: data,
is_reviewed: data.is_reviewed,
review_rating: data.review_rating,
trans_status: data.trans_status,
numberId: data.id.substring(0, 5).toUpperCase()
})
}).catch(error => {
let response = error.response.data;
Alert.alert(error ,response.msg);
Alert.alert(error, response.msg);
this.setState({
indicator: false,
})
// Alert.alert(response.msg);
})
}
rating(){
let paramater = {
session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans,
rating: this.state.rating,
review: this.state.review,
lat: this.props.lat,
long: this.props.long
}
console.log("INI PARAMS"+ JSON.stringify(paramater) );
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/review/transaction', paramater).then(res => {
Alert.alert('','Terimakasih Atas masukan anda!')
this.props.navigation.navigate('Home');
}).catch(error => {
console.log ("INI error " + error)
let response = error.response.data;
Alert.alert(error,response.msg);
})
}
render() {
console.log(this.state.detail_trans)
// console.log(this.state.detail_trans.used_reward)
......@@ -156,11 +147,20 @@ class OrderDetail extends React.Component {
textAlign='center'
/>
</View>
<TouchableOpacity onPress={() => this.handleOrderCancel()}>
<View style={styles.button2}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 22 }}>Confirm</Text>
</View>
</TouchableOpacity>
<View>
</View>
<View style={{margin:5}}>
<TouchableOpacity style={{marginBottom:10}} onPress={() => this.handleOrderCancel()}>
<View style={styles.button2}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>Cancel</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.handleBack()}>
<View style={styles.button2}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>Back</Text>
</View>
</TouchableOpacity>
</View>
</View>
</View>
......@@ -251,7 +251,7 @@ class OrderDetail extends React.Component {
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'grey' }}>{this.state.detail_trans.used_reward[0].reward.title}</Text>
</View>
<View style={{ flex: 0.5, marginVertical: 5, alignItems: 'flex-end', marginRight: 10 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Reward Detail', { rewardId: this.state.detail_trans.used_reward[0].id})}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Reward Detail', { rewardId: this.state.detail_trans.used_reward[0].id })}>
<Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: '#CFB368' }}>View Detail</Text>
</TouchableOpacity>
{/* <NumberFormat decimalScale={0} value={this.state.detail_trans.point_reduce} renderText={value => <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'grey' }}>Rp. {value}</Text>} displayType={'text'} thousandSeparator={true} prefix={''} /> */}
......@@ -344,31 +344,35 @@ class OrderDetail extends React.Component {
{
this.state.trans_status == 0 ? (<TouchableOpacity onPress={() => this.handleCancel()}>
<View style={styles.button}>
<Text style={{ color: 'white', fontSize: 16, fontFamily: 'Gotham-Black' }}>Cancel</Text>
</View>
</TouchableOpacity>) : (null)
<View style={styles.button}>
<Text style={{ color: 'white', fontSize: 16, fontFamily: 'Gotham-Black' }}>Cancel</Text>
</View>
</TouchableOpacity>) : (null)
}
{
this.state.trans_status == 4 ? (
null
this.state.is_reviewed ? (
<View style={{ height: 70, borderWidth: 1, borderRadius: 10, justifyContent: 'center', margin: 30, borderColor: '#CFB368' }}>
<Text style={{ fontFamily: 'Gotham-Light', color: '#838383', fontSize: 16, textAlign: 'center', paddingHorizontal: 5 }}>Rate Your Star ({this.state.review_rating}) </Text>
<Rating imageSize={20} style={{ top: 5 }} readonly startingValue={this.state.review_rating} ratingBackgroundColor='#CFB368' />
</View>
) : (
<TouchableOpacity style={{ justifyContent: 'center' }} onPress={() => this.props.navigation.navigate('RatingOrder', { idTrans: this.state.detail_trans.id })}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginRight: 20, marginLeft: 20, marginTop: 50 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', paddingHorizontal: 5 }}>Rating Order</Text>
</View>
</TouchableOpacity>
)
) : (
<TouchableOpacity style={{ justifyContent: 'center' }} onPress={() => this.props.navigation.navigate('RatingOrder', { idTrans: this.state.detail_trans.id })}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginRight: 20, marginLeft: 20, marginTop: 50 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', paddingHorizontal: 5 }}>Rating Order</Text>
</View>
</TouchableOpacity>
null
)
}
<View style={{ marginVertical: 20 }} />
{/* <TouchableOpacity style={{ justifyContent: 'center' }} onPress={() =>this.rating()}>
<View style={{ height: 40, borderRadius: 10, backgroundColor: '#CFB368', justifyContent: 'center', marginRight: 20, marginLeft: 20, marginTop: 50 }}>
<Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', paddingHorizontal: 5 }}>Rating Order</Text>
</View>
</TouchableOpacity> */}
</ScrollView>
</View>
)
......@@ -432,6 +436,7 @@ const styles = StyleSheet.create({
button2: {
backgroundColor: '#CFB368',
padding: 20,
height: 40,
borderRadius: 10,
paddingVertical: 5,
alignItems: 'center',
......
......@@ -37,10 +37,16 @@ class Outlets extends React.Component {
}
componentDidMount() {
this._getOutletClosest()
this.OrderedList()
this._getPermissions()
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true,
})
this._getOutletClosest()
this.OrderedList()
this._getPermissions()
});
}
_getPermissions = async () => {
......
......@@ -3,6 +3,7 @@ import { View, Text, TextInput, StyleSheet, Button, Alert, TouchableOpacity, Ima
import { Rating, AirbnbRating } from 'react-native-elements';
import { connect } from 'react-redux';
import Axios from 'axios';
import moment from 'moment'
import ActionType from '../redux/globalActionType';
import Spinner from 'react-native-loading-spinner-overlay';
......@@ -13,86 +14,122 @@ class RatingOrder extends React.Component {
this.state = {
review: "",
rating: 5,
outlet: '',
outlet_code: '',
trans_status_display: '',
transaction_detail: [],
numberId: '',
detail_trans: '',
trans_status: '',
modalVisible: false,
}
}
rating(rating){
componentDidMount() {
this.getDetailTrans();
}
getDetailTrans() {
let params = {
session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans
}
// 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 data' + JSON.stringify(data))
// console.log("INI OUTLET "+ data.outlet)
// console.log("OUTLET-CODE" + data.outlet_code)
// console.log("TRANS-DISPLAY" + data.trans_type_display)
this.setState({
outlet: data.outlet,
outlet_code: data.outlet_code,
trans_status_display: data.trans_status_display,
transaction_detail: data.transaction_detail,
detail_trans: data,
trans_status: data.trans_status,
numberId: data.id.substring(0, 5).toUpperCase()
})
}).catch(error => {
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);
})
}
rating(rating) {
this.setState({
rating: rating,
rating: rating,
})
}
review(){
let paramater = {
session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans,
rating: this.state.rating,
review: this.state.review,
lat: this.props.lat,
long: this.props.long
}
console.log("INI PARAMS"+ JSON.stringify(paramater) );
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/review/transaction', paramater).then(res => {
Alert.alert("Terimakasih Atas masukan anda!")
this.props.navigation.navigate('Home');
}).catch(error => {
console.log ("INI error " + error)
let response = error.response.data;
Alert.alert(response.msg);
})
review() {
let paramater = {
session_id: this.props.session_id,
transaction_id: this.props.route.params.idTrans,
rating: this.state.rating,
review: this.state.review,
lat: this.props.lat,
long: this.props.long
}
console.log("INI PARAMS" + JSON.stringify(paramater));
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/review/transaction', paramater).then(res => {
Alert.alert('', 'Terimakasih Atas masukan anda!')
this.props.navigation.navigate('Home');
}).catch(error => {
console.log("INI error " + error)
let response = error.response.data;
Alert.alert(response.msg);
})
}
render() {
return (
<View style={styles.container}>
<Spinner
visible={this.state.spinner}
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/>
<View style={{ flex: 3 }}>
<View style={{ flex: 1, marginRight: 30, marginLeft: 30, top: 50 }}>
<View style={{ height: 100, justifyContent: 'center' }}>
<Text style={{ margin: 20, fontFamily: 'Gotham-Light', fontSize: 14, color: '#838383' }}>How was your experience with your <Text style={{ color: 'red' }}>{this.state.detail_trans.trans_type_display}</Text> order with us {this.state.outlet} on <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', textAlign: 'center', color: '#838383' }}>{moment(this.state.detail_trans.trans_time).format('DD MMMM YYYY HH:mm:ss')}</Text> </Text>
</View>
<View style={{ flex: 1, marginRight: 30, marginLeft: 30, }}>
<AirbnbRating
count={5}
reviews={["Terrible", "Bad", "Meh", "OK", "Good", "Hmm...", "Very Good", ]}
reviews={["Need improvement", "Bellow average", "Average", "Good", "Awesome"]}
onFinishRating={rating => this.rating(rating)}
defaultRating={5}
size={30}
/>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3,top:10}}>Review</Text>
<TextInput style={{ height: 150, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20,top:20 }}
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3, top: 10 }}>Review</Text>
<TextInput style={{ height: 150, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20, top: 20 }}
onChangeText={(review) => this.setState({ review })}
value={this.state.review}
autoCapitalize="none"
value={this.state.review}
/>
<TouchableOpacity style={{ height: 100 }} onPress={()=>this.review()}>
<View style={{ backgroundColor: '#CFB368', height: 45, top: 20, borderRadius: 10, marginRight: 50, marginLeft: 50 }}>
<TouchableOpacity style={{ height: 100 }} onPress={() => this.review()}>
<View style={{ backgroundColor: '#CFB368', height: 40, top: 20, borderRadius: 10, marginRight: 50, marginLeft: 50 }}>
<Text style={{ alignSelf: 'center', top: 10, color: 'white', fontFamily: 'Gotham-Black', fontSize: 20 }}>SUBMIT</Text>
</View>
</TouchableOpacity>
</View>
</View>
<View style={{ flex: 1, flexDirection: 'row' }}>
{/*
<View style={styles.v_logo}>
<View style={{ flex: 1, alignSelf: 'flex-start' }}>
<Image resizeMode="contain" source={require('../assets/images/daun.png')} style={styles.logo}></Image>
</View>
<View style={{ flex: 1 }}>
</View>
</View> */}
<View style={{ flex: 0.5 }}>
</View>
</View>
</View>
......@@ -148,7 +185,7 @@ const styles = StyleSheet.create({
const mapStateToProps = (state) => {
return {
session_id: state.session_id,
lat: state.lat,
long: state.long,
......
......@@ -46,21 +46,32 @@ class UseBalance extends React.Component {
})
}).catch(error => {
// console.log('ini error ' + error)
})
}
redeem(){
if (this.state.current_balance > this.state.redeem) {
Alert.alert('','Balance tidak cukup !')
}else{
Alert.alert('','Balance cukup')
}
}
redeem(){
let params = {
session_id: this.props.session_id,
pin : 123456,
balance: 5000,
point: 5000
}
console.log("INI PARAMS : "+ JSON.stringify(params))
Axios.post('http://excelsocrm.ravintoladev.com/crm/v2/point/redeem', params).then(res => {
console.log('sukses')
}).catch(error => {
let response = error.response.data;
Alert.alert(response.msg);
})
}
render() {
return (
......@@ -71,7 +82,7 @@ class UseBalance extends React.Component {
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(current_balance) => this.setState({ current_balance })}
keyboardType='email-address'>IDR. {this.state.current_balance}</TextInput>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>Redeem</Text>
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3 }}>Point</Text>
<TextInput style={{ height: 40, borderWidth: 1, padding: 5, margin: 10, borderRadius: 10, borderColor: 'grey', fontFamily: 'Gotham-Black', textAlign: 'center', color: 'grey', fontWeight: 'bold', fontSize: 20 }}
onChangeText={(redeem) => this.setState({ redeem })}
autoCapitalize="none"
......
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