// Dependencies
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { nsMerge } from 'shared/utils.mjs'
// Hooks
import { useTranslation } from 'next-i18next'
import { useState, useEffect } from 'react'
import { useBackend } from 'shared/hooks/use-backend.mjs'
// Components
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
import { ns as authNs } from 'shared/components/wrappers/auth/index.mjs'
import { Loading } from 'shared/components/spinner.mjs'
import { PageLink } from 'shared/components/link.mjs'
// Translation namespaces used on this page
const ns = nsMerge(authNs, pageNs, 'status', 'stats')
/*
* Each page MUST be wrapped in the PageWrapper component.
* You also MUST spread props.page into this wrapper component
* when path and locale come from static props (as here)
* or set them manually.
*/
const StatsPage = ({ page }) => {
const { t } = useTranslation(ns)
const backend = useBackend()
const [stats, setStats] = useState(false)
useEffect(() => {
const loadStats = async () => {
const result = await backend.getStats()
if (result.success && result.data) {
setStats(result.data)
}
}
if (!stats) loadStats()
}, [])
if (!stats)
return (
)
return (