Files
pawol.nu/pages/index.js
T
Cédric FAMIBELLE-PRONZOLA 7da21460f9 Add placeholder oki logo
2021-07-22 21:21:01 +02:00

150 lines
4.2 KiB
JavaScript

import {useState} from 'react'
import PropTypes from 'prop-types'
import Image from 'next/image'
import {Box, Button, Container, Grid, Link, Typography, useMediaQuery} from '@material-ui/core'
import {makeStyles} from '@material-ui/core/styles'
import HelpIcon from '@material-ui/icons/Help'
import GroupIcon from '@material-ui/icons/Group'
import MusicNoteIcon from '@material-ui/icons/MusicNote'
import TwitterIcon from '@material-ui/icons/Twitter'
import {Pleroma, Peertube, Nextcloud} from '@icons-pack/react-simple-icons'
import KatKayLa from '../components/kat-kay-la'
import HeadLayout from '../components/head-layout'
import Carousel from '../components/carousel'
import Footer from '../components/footer'
import {jwennTeksKantite, jwennAwtisKantite} from '../lib/oki-api'
import RezoMenu from '../components/rezo-menu'
import JwennSesyon from '../components/jwenn-sesyon'
import okiLogo from '../public/logo-192x110.png'
const useStyles = makeStyles(theme => ({
root: {
'& > *': {
margin: theme.spacing(1.2)
}
}
}))
const REZO = [
{
id: 'mizik',
tit: 'Mizik',
icon: <MusicNoteIcon />
},
{
id: 'pale',
tit: 'Palé',
icon: <Pleroma />
},
{
id: 'gade',
tit: 'Gadé',
icon: <Peertube />
},
{
id: 'mobilize',
tit: 'Mobilizé',
icon: <GroupIcon />
},
{
id: 'niyaj',
tit: 'Niyaj',
icon: <Nextcloud />
}
]
const twitterUrl = `https://twitter.com/${process.env.NEXT_PUBLIC_TWITTER_USERNAME || ''}`
export default function Home({kantiteAwtis, kantiteTeks}) {
const classes = useStyles()
const [handleOpen, setHandleOpen] = useState(false)
const handleClick = () => {
setHandleOpen(true)
}
const kantite = [
{id: 1, tit: 'Kantité Tèks', kantite: kantiteTeks, route: '/teks'},
{id: 2, tit: 'Kantité Awtis', kantite: kantiteAwtis, route: '/awtis?paj&paj=1'}
]
const matches = useMediaQuery('(max-width:600px)')
return (
<HeadLayout tab={0}>
<div style={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
<Container align='center'>
<Image
alt='Logo #OKi'
width={192}
height={110}
src={okiLogo}
placeholder='blur'
/>
<Typography variant='h6' component='h1'>
Organisation KA Internationale
</Typography>
</Container>
<Container className={classes.root} style={{display: 'flex', justifyContent: 'center'}} align='center'>
<Box style={{display: 'flex', flexDirection: 'column'}}>
<RezoMenu data={REZO} />
<JwennSesyon />
</Box>
<Box style={{display: 'flex', flexDirection: 'column'}}>
<Button
startIcon={<HelpIcon style={{fontSize: 25}} />}
size='large'
variant='contained'
color='primary'
onClick={handleClick}
>
Èd
</Button>
<Link target='_blank' rel='noopener noreferrer' href={twitterUrl}>
<Button style={{marginTop: 10}} variant='outlined' color='primary'>
<Box paddingTop={1}>
<TwitterIcon style={{fontSize: 55}} />
<Typography style={{fontWeight: 'bold'}} variant='h6' component='h1'>
Twitter
</Typography>
</Box>
</Button>
</Link>
</Box>
</Container>
<Container style={{marginBlock: '1.5em'}}>
<Grid container spacing={3}>
{kantite.map(k => <KatKayLa key={k.id} tit={k.tit} kantite={k.kantite} route={k.route} />)}
</Grid>
</Container>
<Carousel
isMobile={matches}
handleOpen={handleOpen}
setHandleOpen={setHandleOpen}
/>
<Footer />
</div>
</HeadLayout>
)
}
Home.propTypes = {
kantiteAwtis: PropTypes.number.isRequired,
kantiteTeks: PropTypes.number.isRequired
}
export async function getServerSideProps() {
const awtisResponse = await jwennAwtisKantite()
const teksResponse = await jwennTeksKantite()
const kantiteAwtis = awtisResponse
const kantiteTeks = teksResponse
return {
props: {
kantiteAwtis,
kantiteTeks
}
}
}