Commit e5a92675 authored by Trisno's avatar Trisno

display loading bar and 'No Reward History'

parent e4660d35
import React from 'react';
import { View, Text, Image, StyleSheet, ScrollView, Alert, TouchableOpacity } from 'react-native';
import { View, Text, Image, StyleSheet, ScrollView, Alert, TouchableOpacity, ActivityIndicator } from 'react-native';
import { Card } from 'react-native-shadow-cards'
import { connect } from 'react-redux';
import Axios from 'axios';
......@@ -9,7 +9,8 @@ class RewardHistory extends React.Component {
constructor(props) {
super(props)
this.state = {
rewardsList: []
rewardsList: [],
indicator: true
}
}
......@@ -32,14 +33,15 @@ class RewardHistory extends React.Component {
Axios.post('https://excelsocrm.ravintoladev.com/crm/v2/reward/history', 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")
item.used_time = moment(item.used_time).format("DD MMMM YYYY")
})
// console.log(data)
this.setState({
rewardsList: data
rewardsList: data,
indicator: false
})
}).catch(error => {
......@@ -52,7 +54,8 @@ class RewardHistory extends React.Component {
return (
<View style={styles.container}>
<ScrollView style={styles.body}>
{
{this.state.indicator ? (<ActivityIndicator style={{ justifyContent: "center", alignItems: 'center', margin: 20 }} size="large" color="#c9af6d" />) :
this.state.rewardsList.length ? (
this.state.rewardsList.map((item, key) => (
<TouchableOpacity key={key} onPress={() => this.props.navigation.navigate('Reward Detail', { rewardId: item.id })}>
<View style={{ alignItems: 'center' }}>
......@@ -63,20 +66,27 @@ class RewardHistory extends React.Component {
resizeMode='cover'
style={{ height: 100, width: '100%' }} />
</View>
<View style={{ flexDirection: 'row', justifyContent:'space-between', padding:10 }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between', padding: 10 }}>
<View>
<Text style={{textAlign:'left', fontSize: 12, fontFamily: 'Gotham-Black'}}>{item.reward.title}</Text>
<Text style={{textAlign:'left', fontSize: 12, fontFamily: 'Gotham-Light'}}>{item.reward.subtitle}</Text>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Black' }}>{item.reward.title}</Text>
<Text style={{ textAlign: 'left', fontSize: 12, fontFamily: 'Gotham-Light' }}>{item.reward.subtitle}</Text>
</View>
<View>
<Text style={{textAlign:'right',fontSize: 12, fontFamily: 'Gotham-Light'}}>Used at</Text>
<Text style={{textAlign:'right', fontSize: 12, fontFamily: 'Gotham-Light'}}>{item.used_time}</Text>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light' }}>Used at</Text>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light' }}>{item.used_time}</Text>
</View>
</View>
</Card>
</View>
</TouchableOpacity>
))
) : (
<View style={{ alignItems: 'center', margin: 20 }}>
<Text style={{ textAlign: 'right', fontSize: 12, fontFamily: 'Gotham-Light' }}>No Reward History</Text>
</View>
)
}
</ScrollView>
</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