import styles from './styles.module.scss'; import React, {useEffect} from "react"; import {useDispatch, useSelector} from "react-redux"; import {reqAgentHistory} from "@features/api"; import {getAgentHistory, getAgentHistoryStatus} from "@features/agentSlice"; import {REQ_STATUS} from "@api/config"; import SmallLoading from "@components/SmallLoading"; import Spring from "@components/Spring"; import {formatCash} from "@utils/helpers"; const i18n=global.i18n; const WAgentHistory = ({close}) => { const dispatch = useDispatch(); const status=useSelector(getAgentHistoryStatus); const history=useSelector(getAgentHistory); useEffect(() => { dispatch(reqAgentHistory()); }, []); const renderList=()=>{ if (status===REQ_STATUS.LOADING){ return (
) } let len=history.length; return ( { history.map((item,index)=>{ let Date=item.Date+""; let DateStr=Date.substring(0,4)+"-"+Date.substring(4,6)+"-"+Date.substring(6,8); let bonus=item.bonus; let bonusStr=global.DOLLAR+formatCash(bonus,2,true); let bg_style=index===len-1?styles.info_item_bottom:styles.info_item_middle; return (
{DateStr} {bonusStr} {i18n.t("agent.history.status_1")}
) }) }
) } const renderContent=()=>{ return (
{i18n.t("agent.bonus.label_date")}
{i18n.t("agent.bonus.label_commision")}
{i18n.t("agent.history.label_status")}
{renderList()}
) } return (
{renderContent()}
) } export default WAgentHistory;