| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import { useTheme } from '@mui/material/styles'; |
| | | import { useTranslate, useAuthProvider, Title } from 'react-admin'; |
| | | import { useTranslate, useAuthProvider, Title, useNotify } from 'react-admin'; |
| | | import { WordEffect } from './WordEffect'; |
| | | import { getSystemDicts } from '@/api/auth' |
| | | import Welcome from "./Welcome"; |
| | | import CardWithIcon from '../components/CardWithIcon'; |
| | | import SensorOccupiedIcon from '@mui/icons-material/SensorOccupied'; |
| | | import WifiIcon from '@mui/icons-material/Wifi'; |
| | | import request from '@/utils/request'; |
| | | import { Box, Typography, LinearProgress, Stack } from '@mui/material'; |
| | | |
| | | const Dashboard = () => { |
| | | const authProvider = useAuthProvider(); |
| | |
| | | <> |
| | | <Title title={"menu.dashboard"} /> |
| | | <Welcome /> |
| | | <DashboardSummaryView /> |
| | | <div |
| | | style={{ |
| | | boxSizing: 'border-box', |
| | |
| | | ) |
| | | } |
| | | |
| | | const DashboardSummaryView = () => { |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const [statistic, setStatistic] = useState(null); |
| | | |
| | | useEffect(() => { |
| | | request.get('/dashboard/member/statistic', { |
| | | params: {} |
| | | }).then(res => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | setStatistic(data); |
| | | } else { |
| | | notify(msg, { type: 'error', messageArgs: { _: msg } }); |
| | | } |
| | | }).catch((error) => { |
| | | notify(error.message, { type: 'error', messageArgs: { _: error.message } }); |
| | | console.error(error); |
| | | }) |
| | | }, []) |
| | | |
| | | return ( |
| | | <Box sx={{ |
| | | display: 'flex', |
| | | mt: 2, |
| | | gap: 2, |
| | | justifyContent: 'space-between', |
| | | }}> |
| | | <CardWithIcon |
| | | icon={WifiIcon} |
| | | title={translate('page.member.header.onlineMembers')} |
| | | subtitle={`${statistic?.membersOnlineQua}`} |
| | | /> |
| | | <CardWithIcon |
| | | icon={SensorOccupiedIcon} |
| | | title={translate('page.member.header.totalMembers')} |
| | | subtitle={`${statistic?.membersTotalQua}`} |
| | | /> |
| | | <CardWithIcon |
| | | icon={WifiIcon} |
| | | title={translate('page.member.header.onlineMembers')} |
| | | subtitle={`${statistic?.membersOnlineQua}`} |
| | | /> |
| | | <CardWithIcon |
| | | icon={SensorOccupiedIcon} |
| | | title={translate('page.member.header.totalMembers')} |
| | | subtitle={`${statistic?.membersTotalQua}`} |
| | | /> |
| | | </Box> |
| | | ) |
| | | } |
| | | |
| | | export default Dashboard; |