import PropTypes from 'prop-types'
import Container from '@mui/material/Container'
import Typography from '@mui/material/Typography'
import Box from '@mui/material/Box'
import Divider from '@mui/material/Divider'
import Chip from '@mui/material/Chip'
import Grid from '@mui/material/Grid'
import ArrowCircleDownIcon from '@mui/icons-material/ArrowCircleDown'
import HeadLayout from '../components/head-layout'
import Footer from '../components/footer'
import RezoDialog from '../components/rezo/rezo-dialog'
import {jwennStats} from '../lib/oki-api'
import KatStats from '../components/stats/kat-stats'
import KatKayLa from '../components/kat-kay-la'
import Custom500 from './500'
export default function Home({errorCode, errorMessage, stats}) {
if (errorCode) {
console.log('⚠️ error', errorMessage)
return
}
const {parolesWithoutTranslation} = stats
const statsByLang = [
{
code: 'fr',
value: parolesWithoutTranslation.francais,
emoji: '🇫🇷'
},
{
code: 'en',
value: parolesWithoutTranslation.anglais,
emoji: '🇬🇧'
},
{
code: 'es',
value: parolesWithoutTranslation.espagnol,
emoji: '🇪🇸'
},
{
code: 'de',
value: parolesWithoutTranslation.allemand,
emoji: '🇩🇪'
},
{
code: 'it',
value: parolesWithoutTranslation.italien,
emoji: '🇮🇹'
}
]
return (
#OKi
Organisation KA Internationale
Paroles, traductions et Fediverse
} label='Statistiques' variant='outlined' />
Traductions
{statsByLang.map(({code, value, emoji}) => (
))}
)
}
export async function getServerSideProps() {
let stats
let errorCode
let errorMessage
try {
stats = await jwennStats()
} catch (error) {
errorMessage = error.message
errorCode = true
}
return {
props: {
errorCode: errorCode || null,
errorMessage: errorMessage || null,
stats: stats || null
}
}
}
Home.defaultProps = {
errorCode: null,
errorMessage: null,
stats: null
}
Home.propTypes = {
errorCode: PropTypes.bool,
errorMessage: PropTypes.string,
stats: PropTypes.object
}