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 Divider from '@mui/material/Divider'
|
|
|
|
|
import Chip from '@mui/material/Chip'
|
|
|
|
|
import Grid from '@mui/material/Grid'
|
2022-06-17 22:18:17 +04:00
|
|
|
import Button from '@mui/material/Button'
|
2022-05-10 02:10:06 +04:00
|
|
|
import ArrowCircleDownIcon from '@mui/icons-material/ArrowCircleDown'
|
2022-06-19 02:36:22 +04:00
|
|
|
import OpenInNewIcon from '@mui/icons-material/OpenInNew'
|
2022-08-20 22:33:32 +04:00
|
|
|
import FormHelperText from '@mui/material/FormHelperText'
|
2022-09-09 23:23:14 +04:00
|
|
|
import Tooltip from '@mui/material/Tooltip'
|
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'
|
|
|
|
|
|
2022-05-25 06:40:00 +04:00
|
|
|
import KatStats from '../components/stats/kat-stats'
|
2022-05-23 00:25:46 +04:00
|
|
|
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} />
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-25 06:40:00 +04:00
|
|
|
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: '🇮🇹'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
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'}}>
|
2022-05-23 00:25:46 +04:00
|
|
|
<Box sx={{flexGrow: 1, marginBottom: 3, marginTop: 1}}>
|
2022-05-10 02:10:06 +04:00
|
|
|
<Container sx={{marginBottom: 2}} align='center'>
|
2022-02-01 20:59:38 +04:00
|
|
|
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h1'>
|
2022-01-22 12:31:55 +04:00
|
|
|
#OKi
|
|
|
|
|
</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-08-20 22:33:32 +04:00
|
|
|
<Container>
|
|
|
|
|
<Grid container justifyContent='center' spacing={2}>
|
|
|
|
|
<Grid item>
|
2022-09-09 23:23:14 +04:00
|
|
|
<Tooltip title='asso.oki.re' placement='top' arrow>
|
2022-08-20 22:33:32 +04:00
|
|
|
<Button variant='outlined' endIcon={<OpenInNewIcon />} onClick={() => window.open('https://asso.oki.re/public/members/new.php', '_blank')}>
|
|
|
|
|
<strong>Adhésion</strong>
|
|
|
|
|
</Button>
|
2022-09-09 23:23:14 +04:00
|
|
|
</Tooltip>
|
2022-08-20 22:33:32 +04:00
|
|
|
</Grid>
|
|
|
|
|
<Grid item>
|
2022-09-09 23:23:14 +04:00
|
|
|
<Tooltip title='o-k-i.net' placement='top' arrow>
|
|
|
|
|
<Button variant='outlined' endIcon={<OpenInNewIcon />} onClick={() => window.open('https://o-k-i.net', '_blank')}>
|
|
|
|
|
<strong>Fédiverse</strong>
|
|
|
|
|
</Button>
|
|
|
|
|
</Tooltip>
|
2022-08-20 22:33:32 +04:00
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
2022-01-20 18:01:52 +04:00
|
|
|
</Container>
|
|
|
|
|
</Box>
|
2022-05-14 03:37:04 +04:00
|
|
|
<Container sx={{flexGrow: 100}}>
|
2022-05-23 00:25:46 +04:00
|
|
|
<Divider sx={{marginBottom: 3}}>
|
|
|
|
|
<Chip sx={{fontWeight: 'bold'}} color='primary' icon={<ArrowCircleDownIcon />} label='Statistiques' variant='outlined' />
|
2022-05-14 01:37:55 +04:00
|
|
|
</Divider>
|
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-06-04 01:38:19 +04:00
|
|
|
<Typography marginBottom={2} textAlign='center' sx={{fontWeight: 'bold'}} variant='h6' component='h4'>
|
|
|
|
|
Traductions
|
|
|
|
|
</Typography>
|
|
|
|
|
<Grid container justifyContent='space-between' spacing={2} marginBottom={3}>
|
2022-05-25 06:40:00 +04:00
|
|
|
{statsByLang.map(({code, value, emoji}) => (
|
|
|
|
|
<KatStats key={code} emoji={emoji} value={value} total={stats.countParole} />
|
|
|
|
|
))}
|
2022-06-02 07:41:38 +04:00
|
|
|
</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
|
|
|
}
|