import {Box, Icon, SimpleGrid, useColorModeValue} from '@chakra-ui/react' import {graphql, useStaticQuery} from 'gatsby' import {List} from './components/Dashboard/List/List' import {ListItem} from './components/Dashboard/List/ListItem' import {Stat} from './components/Dashboard/Stats/Stat' import {StatLabel} from './components/Dashboard/Stats/StatLabel' import {StatNumber} from './components/Dashboard/Stats/StatNumber' import {FaRocket} from '@react-icons/all-files/fa/FaRocket' import {IRemoteFileMigration} from '..' import {useAppSelector} from '../redux' import {useChanges} from '../services/hooks' import UndrawThoughts from './components/Dashboard/assets/undraw_thoughts_re_3ysu.svg' const useStats = () => { try { return useStaticQuery<{ allJaenNotification: { totalCount: number } allJaenPage: { totalCount: number } jaenInternal: { migrationHistory: Array } }>(graphql` query DashboardTab { allJaenNotification { totalCount } allJaenPage { totalCount } jaenInternal { migrationHistory { fileUrl createdAt } } } `) } catch (e) { return { allJaenNotification: {totalCount: Infinity}, allJaenPage: {totalCount: Infinity}, jaenInternal: {migrationHistory: []} } } } export const DashboardTab = () => { const { allJaenNotification, allJaenPage, jaenInternal: {migrationHistory} } = useStats() const {totalChanges} = useChanges() const data = [ {label: 'Total pages', value: allJaenPage.totalCount}, {label: 'Total notifications', value: allJaenNotification.totalCount}, {label: 'Unpublished changes', value: totalChanges} ] const isPublishing = useAppSelector(state => state.status.isPublishing) return ( <> {data.map(({label, value}) => ( {label} {value} ))} {isPublishing && ( } /> )} {migrationHistory .sort((a, b) => new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1 ) .map((m, i) => ( } isLastItem={i === migrationHistory.length - 1} /> ))} ) } export default DashboardTab