diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index f75d3d2fd..9a5442f9d 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -736,10 +736,11 @@ "refer":{ "refer_earn": "Refer & Earn", "refer": "Refer", - "rewarded": "Rewarded", - "not_rewarded": "Not Rewarded", + "rewarded": "Referral points rewarded", + "not_rewarded": "Referral reward pending", "delegate_hp": "Delegate HP", "earned": "Points Earned", - "pending": "Pending Points" + "pending": "Pending Points", + "empty_text": "Referrals let you earn upto 100 Ecency points per referral. Refer your loved ones today and earn free points", } } diff --git a/src/screens/referScreen/referScreen.tsx b/src/screens/referScreen/referScreen.tsx index cd0aed9ec..2c3d89cc8 100644 --- a/src/screens/referScreen/referScreen.tsx +++ b/src/screens/referScreen/referScreen.tsx @@ -1,8 +1,8 @@ import React, { Fragment } from 'react'; import { useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; -import { FlatList, Share, Text, TouchableOpacity, View } from 'react-native'; -import { BasicHeader, Icon, MainButton, PopoverWrapper, UserListItem } from '../../components'; +import { ActivityIndicator, FlatList, Share, Text, TouchableOpacity, View } from 'react-native'; +import { BasicHeader, Icon, ListPlaceHolder, MainButton, PopoverWrapper, UserListItem } from '../../components'; import get from 'lodash/get'; // utils import { getReferralsList } from '../../providers/ecency/ecency'; @@ -23,6 +23,8 @@ const ReferScreen = ({ navigation }) => { const [referralsList, setReferralsList] = useState([]); const [earnedPoints, setEarnedPoint] = useState(0); const [pendingPoints, setPendingPoint] = useState(0); + const [loading, setLoading] = useState(true); + useEffect(() => { _getReferralsList(); }, []); @@ -30,8 +32,9 @@ const ReferScreen = ({ navigation }) => { console.log('-----referralsList----- : ', referralsList); const _getReferralsList = async () => { - // const referralsListData = await getReferralsList('good-karma'); // using 'good-karma' name for testing, use original name here - const referralsListData = await getReferralsList(currentAccount.name); + setLoading(true); + const referralsListData = await getReferralsList('good-karma'); // using 'good-karma' name for testing, use original name here + // const referralsListData = await getReferralsList(currentAccount.name); let rewardedPoints = 0; let unrewardedPoint = 0; referralsListData.forEach((value) => { @@ -41,6 +44,7 @@ const ReferScreen = ({ navigation }) => { unrewardedPoint += 100; } }); + setLoading(false); setReferralsList(referralsListData as any); setEarnedPoint(rewardedPoints); setPendingPoint(unrewardedPoint); @@ -74,7 +78,7 @@ const ReferScreen = ({ navigation }) => { {pendingPoints} - + {intl.formatMessage({ id: 'refer.pending', })} @@ -95,7 +99,7 @@ const ReferScreen = ({ navigation }) => { })} - + @@ -133,6 +137,10 @@ const ReferScreen = ({ navigation }) => { ); }; + const _renderEmptyView = ( + loading ? () + :({intl.formatMessage({id:'refer.empty_text'})})); + const _renderReferralListItem = ({ item, index }: { item: Referral; index: number }) => { return ( { // refreshing={refreshing} keyExtractor={(item, index) => `item ${index}`} removeClippedSubviews={false} - // ListEmptyComponent={} + ListEmptyComponent={_renderEmptyView} // onRefresh={() => fetchLeaderBoard()} renderItem={_renderReferralListItem} contentContainerStyle={styles.listContentContainer} diff --git a/src/screens/referScreen/referScreenStyles.ts b/src/screens/referScreen/referScreenStyles.ts index 68b754d9c..550cbc54f 100644 --- a/src/screens/referScreen/referScreenStyles.ts +++ b/src/screens/referScreen/referScreenStyles.ts @@ -10,10 +10,10 @@ export default EStyleSheet.create({ marginBottom: 16, }, earnedWrapper: { - marginRight: 8, + marginRight: 32, }, pendingWrapper: { - marginLeft: 8, + marginLeft: 32, }, points: { color: '$primaryBlue', @@ -29,11 +29,13 @@ export default EStyleSheet.create({ justifyContent: 'center', marginTop: 5, }, - pendingText: { - color: '$primaryDarkGray', + emptyText:{ + color: '$primaryDarkText', fontSize: 16, justifyContent: 'center', marginTop: 5, + padding: 32, + textAlign:'center' }, mainButton: { marginTop: 16,