2022-05-14 01:37:55 +04:00
|
|
|
import PropTypes from 'prop-types'
|
2022-05-25 06:39:40 +04:00
|
|
|
import Container from '@mui/material/Container'
|
|
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
|
import Grid from '@mui/material/Grid'
|
2020-12-17 09:08:18 +01:00
|
|
|
|
2020-12-15 23:46:05 +01:00
|
|
|
import HeadLayout from '../components/head-layout'
|
2021-06-14 23:30:00 +02:00
|
|
|
import Footer from '../components/footer'
|
2022-05-23 00:25:46 +04:00
|
|
|
import {jwennStats} from '../lib/oki-api'
|
|
|
|
|
|
|
|
|
|
import KatKayLa from '../components/kat-kay-la'
|
2020-12-17 22:36:27 +01:00
|
|
|
|
2022-05-14 03:37:04 +04:00
|
|
|
import Custom500 from './500'
|
|
|
|
|
|
2022-05-23 00:25:46 +04:00
|
|
|
export default function Home({errorCode, errorMessage, stats}) {
|
2022-05-14 03:37:04 +04:00
|
|
|
if (errorCode) {
|
|
|
|
|
console.log('⚠️ error', errorMessage)
|
|
|
|
|
return <Custom500 statusCode={errorCode} />
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-04 20:16:24 +01:00
|
|
|
return (
|
2020-12-15 23:46:05 +01:00
|
|
|
<HeadLayout tab={0}>
|
2022-01-20 18:01:52 +04:00
|
|
|
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
|
2023-03-05 13:46:21 +04:00
|
|
|
<Box sx={{flexGrow: 1, marginBottom: 3, marginTop: 3}}>
|
|
|
|
|
<Container align='center'>
|
2022-02-01 20:59:38 +04:00
|
|
|
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h1'>
|
2023-03-20 20:12:20 +04:00
|
|
|
OKI
|
2022-01-22 12:31:55 +04:00
|
|
|
</Typography>
|
2022-02-01 20:59:38 +04:00
|
|
|
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h2'>
|
2022-01-20 18:01:52 +04:00
|
|
|
Organisation KA Internationale
|
|
|
|
|
</Typography>
|
2022-02-01 23:44:18 +04:00
|
|
|
<Typography sx={{fontStyle: 'italic'}} variant='caption' component='h3'>
|
2022-06-19 02:20:56 +04:00
|
|
|
Paroles, traductions et Fédiverse
|
2022-02-01 20:59:38 +04:00
|
|
|
</Typography>
|
|
|
|
|
</Container>
|
2022-01-20 18:01:52 +04:00
|
|
|
</Box>
|
2022-05-14 03:37:04 +04:00
|
|
|
<Container sx={{flexGrow: 100}}>
|
2022-05-23 00:25:46 +04:00
|
|
|
<Grid container spacing={2} sx={{marginBottom: 3}}>
|
2022-05-23 18:34:55 +04:00
|
|
|
<KatKayLa tit='Paroles' kantite={stats.countParole} href='/paroles' as='/paroles' />
|
2022-05-23 00:25:46 +04:00
|
|
|
<KatKayLa tit='Artistes' kantite={stats.countArtiste} href='/awtis?paj&paj=1' as='/awtis/paj/1' />
|
|
|
|
|
</Grid>
|
2022-05-08 23:49:37 +04:00
|
|
|
</Container>
|
2021-06-14 23:30:00 +02:00
|
|
|
<Footer />
|
2022-01-20 18:01:52 +04:00
|
|
|
</Box>
|
2020-12-15 23:46:05 +01:00
|
|
|
</HeadLayout>
|
2020-12-04 20:16:24 +01:00
|
|
|
)
|
|
|
|
|
}
|
2022-05-08 23:49:37 +04:00
|
|
|
|
2022-05-14 01:37:55 +04:00
|
|
|
export async function getServerSideProps() {
|
2022-05-23 00:25:46 +04:00
|
|
|
let stats
|
2022-05-14 03:37:04 +04:00
|
|
|
let errorCode
|
|
|
|
|
let errorMessage
|
|
|
|
|
|
|
|
|
|
try {
|
2022-05-23 00:25:46 +04:00
|
|
|
stats = await jwennStats()
|
2022-05-14 03:37:04 +04:00
|
|
|
} catch (error) {
|
|
|
|
|
errorMessage = error.message
|
|
|
|
|
errorCode = true
|
|
|
|
|
}
|
2022-05-14 01:37:55 +04:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
2022-05-14 03:37:04 +04:00
|
|
|
errorCode: errorCode || null,
|
|
|
|
|
errorMessage: errorMessage || null,
|
2022-05-23 00:25:46 +04:00
|
|
|
stats: stats || null
|
2022-05-14 01:37:55 +04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-14 03:37:04 +04:00
|
|
|
Home.defaultProps = {
|
|
|
|
|
errorCode: null,
|
|
|
|
|
errorMessage: null,
|
2022-05-23 00:25:46 +04:00
|
|
|
stats: null
|
2022-05-14 03:37:04 +04:00
|
|
|
}
|
|
|
|
|
|
2022-05-14 01:37:55 +04:00
|
|
|
Home.propTypes = {
|
2022-05-14 03:37:04 +04:00
|
|
|
errorCode: PropTypes.bool,
|
|
|
|
|
errorMessage: PropTypes.string,
|
2022-05-23 00:25:46 +04:00
|
|
|
stats: PropTypes.object
|
2022-05-14 01:37:55 +04:00
|
|
|
}
|