Commit 0f3a3559 authored by Trisno's avatar Trisno

update reward select dan reward list

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