Files
pawol.nu/pages/index.js
T

150 lines
4.2 KiB
JavaScript
Raw Normal View History

2020-12-17 09:08:18 +01:00
import {useState} from 'react'
2020-12-17 22:36:27 +01:00
import PropTypes from 'prop-types'
import Image from 'next/image'
2021-07-22 20:29:25 +02:00
import {Box, Button, Container, Grid, Link, Typography, useMediaQuery} from '@material-ui/core'
2021-07-19 23:41:59 +02:00
import {makeStyles} from '@material-ui/core/styles'
2021-05-02 14:30:07 +02:00
import HelpIcon from '@material-ui/icons/Help'
2021-07-19 23:41:59 +02:00
import GroupIcon from '@material-ui/icons/Group'
import MusicNoteIcon from '@material-ui/icons/MusicNote'
2021-07-22 20:29:25 +02:00
import TwitterIcon from '@material-ui/icons/Twitter'
2021-07-20 19:30:28 +02:00
import {Pleroma, Peertube, Nextcloud} from '@icons-pack/react-simple-icons'
2020-12-17 09:08:18 +01:00
2020-12-17 22:36:27 +01:00
import KatKayLa from '../components/kat-kay-la'
2020-12-15 23:46:05 +01:00
import HeadLayout from '../components/head-layout'
2020-12-17 09:08:18 +01:00
import Carousel from '../components/carousel'
2021-06-14 23:30:00 +02:00
import Footer from '../components/footer'
import {jwennTeksKantite, jwennAwtisKantite} from '../lib/oki-api'
2021-07-19 23:41:59 +02:00
import RezoMenu from '../components/rezo-menu'
2021-07-22 01:00:17 +02:00
import JwennSesyon from '../components/jwenn-sesyon'
2021-07-19 23:41:59 +02:00
2021-07-22 21:21:01 +02:00
import okiLogo from '../public/logo-192x110.png'
2021-07-19 23:41:59 +02:00
const useStyles = makeStyles(theme => ({
root: {
'& > *': {
2021-07-22 01:00:17 +02:00
margin: theme.spacing(1.2)
2021-07-19 23:41:59 +02:00
}
}
}))
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 />
2021-07-20 19:30:28 +02:00
},
{
id: 'niyaj',
tit: 'Niyaj',
icon: <Nextcloud />
2021-07-19 23:41:59 +02:00
}
]
2020-12-04 20:16:24 +01:00
2021-07-22 20:29:25 +02:00
const twitterUrl = `https://twitter.com/${process.env.NEXT_PUBLIC_TWITTER_USERNAME || ''}`
2020-12-18 22:01:47 +01:00
export default function Home({kantiteAwtis, kantiteTeks}) {
2021-07-19 23:41:59 +02:00
const classes = useStyles()
2020-12-17 09:08:18 +01:00
const [handleOpen, setHandleOpen] = useState(false)
const handleClick = () => {
setHandleOpen(true)
}
2020-12-18 22:01:47 +01:00
const kantite = [
2021-05-28 17:17:25 +02:00
{id: 1, tit: 'Kantité Tèks', kantite: kantiteTeks, route: '/teks'},
{id: 2, tit: 'Kantité Awtis', kantite: kantiteAwtis, route: '/awtis?paj&paj=1'}
2020-12-17 22:36:27 +01:00
]
2020-12-17 09:08:18 +01:00
const matches = useMediaQuery('(max-width:600px)')
2020-12-04 20:16:24 +01:00
return (
2020-12-15 23:46:05 +01:00
<HeadLayout tab={0}>
2021-06-14 23:30:00 +02:00
<div style={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
<Container align='center'>
<Image
alt='Logo #OKi'
width={192}
height={110}
2021-07-22 21:21:01 +02:00
src={okiLogo}
placeholder='blur'
2021-06-14 23:30:00 +02:00
/>
<Typography variant='h6' component='h1'>
Organisation KA Internationale
</Typography>
</Container>
2021-07-22 20:29:25 +02:00
<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>
2021-07-22 01:00:17 +02:00
</Container>
2021-07-19 23:41:59 +02:00
<Container style={{marginBlock: '1.5em'}}>
2021-06-14 23:30:00 +02:00
<Grid container spacing={3}>
{kantite.map(k => <KatKayLa key={k.id} tit={k.tit} kantite={k.kantite} route={k.route} />)}
2021-05-06 20:28:44 +02:00
</Grid>
2021-06-14 23:30:00 +02:00
</Container>
<Carousel
isMobile={matches}
handleOpen={handleOpen}
setHandleOpen={setHandleOpen}
/>
<Footer />
</div>
2020-12-15 23:46:05 +01:00
</HeadLayout>
2020-12-04 20:16:24 +01:00
)
}
2020-12-11 01:38:05 +01:00
2020-12-17 22:36:27 +01:00
Home.propTypes = {
2020-12-18 22:01:47 +01:00
kantiteAwtis: PropTypes.number.isRequired,
kantiteTeks: PropTypes.number.isRequired
2020-12-17 22:36:27 +01:00
}
2020-12-11 01:38:05 +01:00
export async function getServerSideProps() {
const awtisResponse = await jwennAwtisKantite()
const teksResponse = await jwennTeksKantite()
const kantiteAwtis = awtisResponse
const kantiteTeks = teksResponse
2020-12-11 01:38:05 +01:00
return {
props: {
2020-12-18 22:01:47 +01:00
kantiteAwtis,
kantiteTeks
2020-12-11 01:38:05 +01:00
}
}
}