|
@@ -1,15 +1,16 @@
|
|
|
import { makeStyles, Theme, Typography } from '@material-ui/core';
|
|
|
+import { useEffect, useMemo, useState } from 'react';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import EmptyCard from '../../components/cards/EmptyCard';
|
|
|
import icons from '../../components/icons/Icons';
|
|
|
import { StatusEnum } from '../../components/status/Types';
|
|
|
import { useNavigationHook } from '../../hooks/Navigation';
|
|
|
+import { CollectionHttp } from '../../http/Collection';
|
|
|
import { ALL_ROUTER_TYPES } from '../../router/Types';
|
|
|
import { formatNumber } from '../../utils/Common';
|
|
|
import CollectionCard from './collectionCard/CollectionCard';
|
|
|
import { CollectionData } from './collectionCard/Types';
|
|
|
import StatisticsCard from './statisticsCard/StatisticsCard';
|
|
|
-import { StatisticsCardProps } from './statisticsCard/Types';
|
|
|
|
|
|
const useStyles = makeStyles((theme: Theme) => ({
|
|
|
collectionTitle: {
|
|
@@ -30,28 +31,45 @@ const Overview = () => {
|
|
|
const classes = useStyles();
|
|
|
const { t: overviewTrans } = useTranslation('overview');
|
|
|
const { t: collectionTrans } = useTranslation('collection');
|
|
|
+ const [statistics, setStatistics] = useState<{
|
|
|
+ collectionCount: number;
|
|
|
+ totalData: number;
|
|
|
+ }>({
|
|
|
+ collectionCount: 0,
|
|
|
+ totalData: 0,
|
|
|
+ });
|
|
|
|
|
|
- const mockStatistics: StatisticsCardProps = {
|
|
|
- data: [
|
|
|
- {
|
|
|
- label: overviewTrans('load'),
|
|
|
- value: formatNumber(4337),
|
|
|
- valueColor: '#07d197',
|
|
|
- },
|
|
|
- {
|
|
|
- label: overviewTrans('all'),
|
|
|
- value: formatNumber(30000),
|
|
|
- valueColor: '#06aff2',
|
|
|
- },
|
|
|
- {
|
|
|
- label: overviewTrans('data'),
|
|
|
- value: overviewTrans('rows', {
|
|
|
- number: formatNumber(209379100),
|
|
|
- }) as string,
|
|
|
- valueColor: '#0689d2',
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
+ useEffect(() => {
|
|
|
+ const fetchData = async () => {
|
|
|
+ const res = await CollectionHttp.getStatistics();
|
|
|
+ setStatistics(res);
|
|
|
+ };
|
|
|
+ fetchData();
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ const statisticsData = useMemo(() => {
|
|
|
+ return {
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ label: overviewTrans('load'),
|
|
|
+ value: formatNumber(4337),
|
|
|
+ valueColor: '#07d197',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: overviewTrans('all'),
|
|
|
+ value: formatNumber(statistics.collectionCount),
|
|
|
+ valueColor: '#06aff2',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: overviewTrans('data'),
|
|
|
+ value: overviewTrans('rows', {
|
|
|
+ number: formatNumber(statistics.totalData),
|
|
|
+ }) as string,
|
|
|
+ valueColor: '#0689d2',
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ }, [overviewTrans, statistics]);
|
|
|
|
|
|
const mockCollections: CollectionData[] = [
|
|
|
{
|
|
@@ -95,7 +113,7 @@ const Overview = () => {
|
|
|
|
|
|
return (
|
|
|
<section className="page-wrapper">
|
|
|
- <StatisticsCard data={mockStatistics.data} />
|
|
|
+ <StatisticsCard data={statisticsData.data} />
|
|
|
<Typography className={classes.collectionTitle}>
|
|
|
{overviewTrans('load')}
|
|
|
</Typography>
|