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 { ...@@ -232,7 +232,7 @@ class AddreesDetail extends React.Component {
<View style={styles.field_detail_addrees}> <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' }} <TextInput style={{ height: 150, borderWidth: 1, padding: 5, flex: 1, margin: 10, borderRadius: 10, borderColor: 'grey', justifyContent: 'flex-start' }}
onChangeText={(description) => this.setState({ description })} onChangeText={(description) => this.setState({ description })}
numberOfLines={10} numberOfLines={10}
......
...@@ -3,6 +3,7 @@ import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity, ...@@ -3,6 +3,7 @@ import { View, Text, TextInput, StyleSheet, ScrollView, Alert, TouchableOpacity,
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 { Rating, AirbnbRating } from 'react-native-elements';
import session from '../function/session'; import session from '../function/session';
import moment from 'moment' import moment from 'moment'
import NumberFormat from 'react-number-format'; import NumberFormat from 'react-number-format';
...@@ -23,7 +24,9 @@ class OrderDetail extends React.Component { ...@@ -23,7 +24,9 @@ class OrderDetail extends React.Component {
detail_trans: '', detail_trans: '',
trans_status: '', trans_status: '',
modalVisible: false, modalVisible: false,
reason: '' reason: '',
is_reviewed: '',
review_rating: 0
} }
...@@ -53,9 +56,16 @@ class OrderDetail extends React.Component { ...@@ -53,9 +56,16 @@ class OrderDetail extends React.Component {
}) })
} }
handleOrderCancel() { handleBack(){
// console.log(this.state.reason) this.setState({
modalVisible: false
})
}
handleOrderCancel() {
if (this.state.reason == '') {
Alert.alert('', 'Reason must be filled !' )
}else{
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.route.params.idTrans,
...@@ -67,13 +77,16 @@ class OrderDetail extends React.Component { ...@@ -67,13 +77,16 @@ class OrderDetail extends React.Component {
Alert.alert(respon, 'Order was canceled') Alert.alert(respon, 'Order was canceled')
this.props.navigation.navigate('Home', { screen: 'ORDER' }); this.props.navigation.navigate('Home', { screen: 'ORDER' });
}).catch(error => { }).catch(error => {
Alert.alert('Error', error.data.msg) let response = error.response.data;
Alert.alert('',response.msg);
}) })
this.setState({ this.setState({
modalVisible: false modalVisible: false
}) })
} }
}
getDetailTrans() { getDetailTrans() {
let params = { let params = {
session_id: this.props.session_id, session_id: this.props.session_id,
...@@ -83,7 +96,7 @@ class OrderDetail extends React.Component { ...@@ -83,7 +96,7 @@ class OrderDetail extends React.Component {
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 data' + JSON.stringify(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("OUTLET-CODE" + data.outlet_code)
// console.log("TRANS-DISPLAY" + data.trans_type_display) // console.log("TRANS-DISPLAY" + data.trans_type_display)
...@@ -93,13 +106,15 @@ class OrderDetail extends React.Component { ...@@ -93,13 +106,15 @@ class OrderDetail extends React.Component {
trans_status_display: data.trans_status_display, trans_status_display: data.trans_status_display,
transaction_detail: data.transaction_detail, transaction_detail: data.transaction_detail,
detail_trans: data, detail_trans: data,
is_reviewed: data.is_reviewed,
review_rating: data.review_rating,
trans_status: data.trans_status, trans_status: data.trans_status,
numberId: data.id.substring(0, 5).toUpperCase() numberId: data.id.substring(0, 5).toUpperCase()
}) })
}).catch(error => { }).catch(error => {
let response = error.response.data; let response = error.response.data;
Alert.alert(error ,response.msg); Alert.alert(error, response.msg);
this.setState({ this.setState({
indicator: false, indicator: false,
}) })
...@@ -108,30 +123,6 @@ class OrderDetail extends React.Component { ...@@ -108,30 +123,6 @@ class OrderDetail extends React.Component {
}) })
} }
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() { render() {
console.log(this.state.detail_trans) console.log(this.state.detail_trans)
// console.log(this.state.detail_trans.used_reward) // console.log(this.state.detail_trans.used_reward)
...@@ -156,11 +147,20 @@ class OrderDetail extends React.Component { ...@@ -156,11 +147,20 @@ class OrderDetail extends React.Component {
textAlign='center' textAlign='center'
/> />
</View> </View>
<TouchableOpacity onPress={() => this.handleOrderCancel()}> <View>
</View>
<View style={{margin:5}}>
<TouchableOpacity style={{marginBottom:10}} onPress={() => this.handleOrderCancel()}>
<View style={styles.button2}> <View style={styles.button2}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 22 }}>Confirm</Text> <Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>Cancel</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity onPress={() => this.handleBack()}>
<View style={styles.button2}>
<Text style={{ color: 'white', fontWeight: 'bold', fontSize: 16 }}>Back</Text>
</View>
</TouchableOpacity>
</View>
</View> </View>
</View> </View>
...@@ -251,7 +251,7 @@ class OrderDetail extends React.Component { ...@@ -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> <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: 'grey' }}>{this.state.detail_trans.used_reward[0].reward.title}</Text>
</View> </View>
<View style={{ flex: 0.5, marginVertical: 5, alignItems: 'flex-end', marginRight: 10 }}> <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> <Text style={{ fontSize: 12, fontFamily: 'Gotham-Light', color: '#CFB368' }}>View Detail</Text>
</TouchableOpacity> </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={''} /> */} {/* <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={''} /> */}
...@@ -352,23 +352,27 @@ class OrderDetail extends React.Component { ...@@ -352,23 +352,27 @@ class OrderDetail extends React.Component {
{ {
this.state.trans_status == 4 ? ( 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 })}> <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 }}> <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> <Text style={{ fontFamily: 'Gotham-Black', color: 'white', fontSize: 16, textAlign: 'center', paddingHorizontal: 5 }}>Rating Order</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
)
) : (
null
) )
} }
<View style={{ marginVertical: 20 }} /> <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> </ScrollView>
</View> </View>
) )
...@@ -432,6 +436,7 @@ const styles = StyleSheet.create({ ...@@ -432,6 +436,7 @@ const styles = StyleSheet.create({
button2: { button2: {
backgroundColor: '#CFB368', backgroundColor: '#CFB368',
padding: 20, padding: 20,
height: 40,
borderRadius: 10, borderRadius: 10,
paddingVertical: 5, paddingVertical: 5,
alignItems: 'center', alignItems: 'center',
......
...@@ -37,9 +37,15 @@ class Outlets extends React.Component { ...@@ -37,9 +37,15 @@ class Outlets extends React.Component {
} }
componentDidMount() { componentDidMount() {
this._unsubscribe = this.props.navigation.addListener('focus', () => {
this.setState({
indicator: true,
})
this._getOutletClosest() this._getOutletClosest()
this.OrderedList() this.OrderedList()
this._getPermissions() this._getPermissions()
});
} }
......
...@@ -3,6 +3,7 @@ import { View, Text, TextInput, StyleSheet, Button, Alert, TouchableOpacity, Ima ...@@ -3,6 +3,7 @@ import { View, Text, TextInput, StyleSheet, Button, Alert, TouchableOpacity, Ima
import { Rating, AirbnbRating } from 'react-native-elements'; import { Rating, AirbnbRating } from 'react-native-elements';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import Axios from 'axios'; import Axios from 'axios';
import moment from 'moment'
import ActionType from '../redux/globalActionType'; import ActionType from '../redux/globalActionType';
import Spinner from 'react-native-loading-spinner-overlay'; import Spinner from 'react-native-loading-spinner-overlay';
...@@ -13,10 +14,59 @@ class RatingOrder extends React.Component { ...@@ -13,10 +14,59 @@ class RatingOrder extends React.Component {
this.state = { this.state = {
review: "", review: "",
rating: 5, 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({ this.setState({
rating: rating, rating: rating,
...@@ -24,7 +74,7 @@ class RatingOrder extends React.Component { ...@@ -24,7 +74,7 @@ class RatingOrder extends React.Component {
}) })
} }
review(){ review() {
let paramater = { let paramater = {
session_id: this.props.session_id, session_id: this.props.session_id,
...@@ -35,14 +85,14 @@ class RatingOrder extends React.Component { ...@@ -35,14 +85,14 @@ class RatingOrder extends React.Component {
long: this.props.long long: this.props.long
} }
console.log("INI PARAMS"+ JSON.stringify(paramater) ); console.log("INI PARAMS" + JSON.stringify(paramater));
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/review/transaction', paramater).then(res => { Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/review/transaction', paramater).then(res => {
Alert.alert("Terimakasih Atas masukan anda!") Alert.alert('', 'Terimakasih Atas masukan anda!')
this.props.navigation.navigate('Home'); this.props.navigation.navigate('Home');
}).catch(error => { }).catch(error => {
console.log ("INI error " + error) console.log("INI error " + error)
let response = error.response.data; let response = error.response.data;
Alert.alert(response.msg); Alert.alert(response.msg);
}) })
...@@ -51,48 +101,35 @@ class RatingOrder extends React.Component { ...@@ -51,48 +101,35 @@ class RatingOrder extends React.Component {
render() { render() {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Spinner
visible={this.state.spinner}
textContent={'Loading...'}
textStyle={styles.spinnerTextStyle}
/>
<View style={{ flex: 3 }}> <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 <AirbnbRating
count={5} count={5}
reviews={["Terrible", "Bad", "Meh", "OK", "Good", "Hmm...", "Very Good", ]} reviews={["Need improvement", "Bellow average", "Average", "Good", "Awesome"]}
onFinishRating={rating => this.rating(rating)} onFinishRating={rating => this.rating(rating)}
defaultRating={5} defaultRating={5}
size={30} size={30}
/> />
<Text style={{ fontFamily: 'Gotham-Black', color: '#CFB368', fontSize: 20, textAlign: 'center', margin: 3,top:10}}>Review</Text> <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 }} <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 })} onChangeText={(review) => this.setState({ review })}
value={this.state.review} value={this.state.review}
autoCapitalize="none" autoCapitalize="none"
value={this.state.review} value={this.state.review}
/> />
<TouchableOpacity style={{ height: 100 }} onPress={()=>this.review()}> <TouchableOpacity style={{ height: 100 }} onPress={() => this.review()}>
<View style={{ backgroundColor: '#CFB368', height: 45, top: 20, borderRadius: 10, marginRight: 50, marginLeft: 50 }}> <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> <Text style={{ alignSelf: 'center', top: 10, color: 'white', fontFamily: 'Gotham-Black', fontSize: 20 }}>SUBMIT</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
<View style={{ flex: 1, flexDirection: 'row' }}> <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 style={{ flex: 0.5 }}>
</View> </View>
</View> </View>
</View> </View>
......
...@@ -46,21 +46,32 @@ class UseBalance extends React.Component { ...@@ -46,21 +46,32 @@ class UseBalance extends React.Component {
}) })
}).catch(error => { }).catch(error => {
// console.log('ini error ' + error) // console.log('ini error ' + error)
}) })
} }
redeem(){ redeem(){
if (this.state.current_balance > this.state.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);
})
}
Alert.alert('','Balance tidak cukup !')
}else{
Alert.alert('','Balance cukup')
}
}
render() { render() {
return ( return (
...@@ -71,7 +82,7 @@ class UseBalance extends React.Component { ...@@ -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 }} <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 })} onChangeText={(current_balance) => this.setState({ current_balance })}
keyboardType='email-address'>IDR. {this.state.current_balance}</TextInput> 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 }} <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 })} onChangeText={(redeem) => this.setState({ redeem })}
autoCapitalize="none" 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