Commit f2d56bfe authored by Wahyu Adjie Prasetyo's avatar Wahyu Adjie Prasetyo
parents a74daa9e 0f3a3559
......@@ -4,12 +4,14 @@ import { Card } from 'react-native-shadow-cards'
import { connect } from 'react-redux';
import Axios from 'axios';
import moment from 'moment'
import ActionType from '../redux/globalActionType';
class RewardSelect extends React.Component {
constructor(props) {
super(props)
this.state = {
rewardsList: []
rewardsList: [],
selectedReward: []
}
}
......@@ -25,12 +27,38 @@ class RewardSelect extends React.Component {
this._unsubscribe()
}
handleSelect(item){
console.log(item)
console.log(this.props.voucher)
console.log(this.props.value_voucher)
// useVoucher() {
// let voucherProps = {
// value_voucher: this.state.value,
// voucher: this.state.code
// }
// this.props.setVoucher(voucherProps);
// this.props.navigation.navigate('Home', { screen: 'MENU' })
// }
handleSelect(item) {
let params = {
session_id: this.props.session_id,
reward_id: item.id
}
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/get_detail', params).then(res => {
// console.log(res.data.reward)
let detail = res.data.reward.reward
let voucherProps = {
value_voucher: detail,
voucher: detail
}
// console.log(voucherProps)
this.props.setVoucher(voucherProps);
// this.props.navigation.navigate('Home', { screen: 'MENU' })
// console.log(this.props.voucher)
// console.log(this.props.value_voucher)
this.props.navigation.goBack()
})
}
getRewardsList() {
let params = {
session_id: this.props.session_id
......@@ -38,7 +66,7 @@ class RewardSelect extends React.Component {
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/get_list', params).then(res => {
let data = res.data.rewards
// console.log(data)
data.map((item,key) => {
data.map((item, key) => {
// console.log(item.expire_time)
item.expire_time = moment(item.expire_time).format("DD MMMM YYYY")
})
......@@ -67,18 +95,18 @@ class RewardSelect extends React.Component {
<Card style={{ padding: 5, margin: 10 }}>
<View>
<Image source={{ uri: item.reward.title_image }}
resizeMethod="scale"
resizeMethod="resize"
resizeMode='stretch'
style={{ height: 150, width: 430 }} />
</View>
<View style={{ flexDirection: 'row', justifyContent:'space-between', padding:10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10 }}>
<View>
<Text>{item.reward.title}</Text>
<Text style={{ fontWeight: 'bold' }}>{item.reward.title}</Text>
<Text>{item.reward.subtitle}</Text>
</View>
<View>
<Text style={{textAlign:'right'}}>Expired</Text>
<Text style={{textAlign:'right'}}>{item.expire_time}</Text>
<Text style={{ textAlign: 'right' }}>Expired</Text>
<Text style={{ textAlign: 'right' }}>{item.expire_time}</Text>
</View>
</View>
</Card>
......@@ -142,4 +170,4 @@ const mapDispatchToProps = (dispacth) => {
}
export default connect(mapStateToProps,mapDispatchToProps)(RewardSelect);
\ No newline at end of file
export default connect(mapStateToProps, mapDispatchToProps)(RewardSelect);
\ No newline at end of file
......@@ -61,13 +61,13 @@ class RewardsList extends React.Component {
<Card style={{ padding: 5, margin: 10 }}>
<View>
<Image source={{ uri: item.reward.title_image }}
resizeMethod="scale"
resizeMethod="resize"
resizeMode='stretch'
style={{ height: 150, width: 430 }} />
</View>
<View style={{ flexDirection: 'row', justifyContent:'space-between', padding:10 }}>
<View>
<Text>{item.reward.title}</Text>
<Text style={{fontWeight:'bold'}}>{item.reward.title}</Text>
<Text>{item.reward.subtitle}</Text>
</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