import styles from './styles.module.scss';
import {useDispatch, useSelector} from "react-redux";
import {getWithdrawRecord, getWithdrawRecordStatus} from "@features/paySlice";
import React, {useEffect, useState} from "react";
import {REQ_STATUS} from "@api/config";
import SmallLoading from "@components/SmallLoading";
import Spring from "@components/Spring";
import {formatCash, formatDate} from "@utils/helpers";
import {CopyToClipboard} from "react-copy-to-clipboard";
import {toast} from "react-toastify";
import SvgIcon from "@components/SvgIcon";
import Popup from "@components/Popup";
import {ReactComponent as SuccssLogo} from '@assets/singlesvg/succss.svg';
import {ReactComponent as PendingLogo} from '@assets/singlesvg/pending.svg';
import {ReactComponent as FailedLogo} from '@assets/singlesvg/failed.svg';
import {ReactComponent as PixLogo} from '@assets/singlesvg/pix.svg';
import {reqWithdrawRecord} from "@features/api";
const i18n=global.i18n;
const stateType = {
ERROR: -1, // 订单错误
CHECKING: 1, // 审核中
SUCCESS: 2, // 提现成功
FAIL: 3, // 提现失败
RECALL: 4, // 订单撤回
PROCESSING: 5, // 处理中
TTP_ERROR: 6, // 三方订单异常
};
const WWithdrawRecord=({close})=>{
const status=useSelector(getWithdrawRecordStatus);
const recordList=useSelector(getWithdrawRecord);
const [showDetails,setShowDetails]=useState(false);
const [detailInfo,setDetailInfo]=useState(null);
const dispatch =useDispatch();
useEffect(()=>{
dispatch(reqWithdrawRecord())
},[])
const getStateTxt=(state)=>{
state=parseInt(state);
switch(state) {
case stateType.CHECKING: {
return i18n.t("withdraw.record.wait");
}
case stateType.SUCCESS: {
return i18n.t("withdraw.record.success");
}
case stateType.PROCESSING: {
return i18n.t("withdraw.record.processing");
}
case stateType.ERROR:
case stateType.FAIL:
case stateType.TTP_ERROR:
case stateType.RECALL: {
return i18n.t("withdraw.record.fail");
}
default: return "error";
}
}
const getStateCls=(state)=>{
state=parseInt(state);
switch(state) {
case stateType.PROCESSING:
case stateType.CHECKING: {
return styles.status_pending;
}
case stateType.SUCCESS: {
return styles.status_success;
}
case stateType.ERROR:
case stateType.FAIL:
case stateType.RECALL: {
return styles.status_failed;
}
default: return styles.status_pending;
}
}
const getStateLogo=(state)=>{
state=parseInt(state);
switch(state) {
case stateType.PROCESSING:
case stateType.CHECKING: {
return PendingLogo;
}
case stateType.SUCCESS: {
return SuccssLogo;
}
case stateType.ERROR:
case stateType.FAIL:
case stateType.RECALL: {
return FailedLogo;
}
default: return PendingLogo;
}
}
const renderContent=()=>{
if (status===REQ_STATUS.LOADING)return (