import React, { useEffect } from 'react'; import { connect, DispatchProp, routerRedux } from 'dva'; import _ from 'lodash'; import { formatMessage } from 'umi-plugin-locale'; import FittedImage from 'react-fitted-image'; import { HomeCommunityModelState } from './model'; import { Inviter } from '@/types/common'; import Label from '@/components/Label'; import List from '@/components/List'; import { dispatch } from '@/utils/utils'; import styles from './style.less'; import { displayPhone } from '@/utils/transform'; const CommunityPage: React.FC = ({ dispatch, refreshingList, loadingList, loadingFinished, errorList, data, refreshingBasic, errorBasic, info, }) => { useEffect(() => { if (!data || errorList) { dispatch({ type: 'homeCommunity/loadList', payload: true }); } if (!info || errorBasic) { dispatch({ type: 'homeCommunity/loadBasic' }); } }, []); const onRefresh = () => { if (refreshingBasic || refreshingList) return; dispatch({ type: 'homeCommunity/loadList', payload: true }); dispatch({ type: 'homeCommunity/loadBasic' }); }; const renderBanner = (
{formatMessage({ id: 'home.community.total' })} +{info ? info.reward : 0} USDT
{formatMessage({ id: 'home.community.totalInvited', }, { num: info ? info.follower : 0, })} {formatMessage({ id: 'home.community.totalAll', }, { num: info ? info.groupScale : 0, })}
dispatch(routerRedux.push('/invite'))} > {formatMessage({ id: 'home.community.invite' })}
); const renderItem = (it: Inviter) => (
{it.avatar ? :
{(it.nickname && it.nickname[0]) || _.last(it.phone) || 'F'}
}
{it.nickname || displayPhone(it.phone)} {formatMessage({ id: 'home.community.time' })}{it.createdAt}
); return (
{renderBanner}
); }; export default connect( ({ homeCommunity } : any) => ({ ...homeCommunity }), )(CommunityPage);