import React, { useState } from 'react'; import { Table, Thead, Tbody, Tr, Th, Td, TableContainer, Flex, Box, Button } from '@chakra-ui/react'; import { BillSourceMap } from '@fastgpt/global/support/wallet/bill/constants'; import { getUserBills } from '@/web/support/wallet/bill/api'; import type { BillItemType } from '@fastgpt/global/support/wallet/bill/type'; import { usePagination } from '@/web/common/hooks/usePagination'; import { useLoading } from '@/web/common/hooks/useLoading'; import dayjs from 'dayjs'; import MyIcon from '@/components/Icon'; import DateRangePicker, { type DateRangeType } from '@/components/DateRangePicker'; import { addDays } from 'date-fns'; import dynamic from 'next/dynamic'; import { useSystemStore } from '@/web/common/system/useSystemStore'; import { useTranslation } from 'next-i18next'; const BillDetail = dynamic(() => import('./BillDetail')); const BillTable = () => { const { t } = useTranslation(); const { Loading } = useLoading(); const [dateRange, setDateRange] = useState({ from: addDays(new Date(), -7), to: new Date() }); const { isPc } = useSystemStore(); const [billDetail, setBillDetail] = useState(); const { data: bills, isLoading, Pagination, getData } = usePagination({ api: getUserBills, pageSize: isPc ? 20 : 10, params: { dateStart: dateRange.from || new Date(), dateEnd: addDays(dateRange.to || new Date(), 1) } }); return ( {bills.map((item) => ( ))}
{t('user.team.Member Name')} {t('user.Time')} {t('user.Source')} {t('user.Application Name')} {t('user.Total Amount')}
{item.memberName} {dayjs(item.time).format('YYYY/MM/DD HH:mm:ss')} {BillSourceMap[item.source]} {t(item.appName) || '-'} {item.total}元
{!isLoading && bills.length === 0 && ( 无使用记录~ )} getData(1)} /> {!!billDetail && setBillDetail(undefined)} />}
); }; export default React.memo(BillTable);