Files
pawol.nu/pages/index.js
T

123 lines
3.1 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-19 23:41:59 +02:00
import {Button, Container, Grid, Typography, useMediaQuery} from '@material-ui/core'
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'
import {Pleroma, Peertube} 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'
const useStyles = makeStyles(theme => ({
root: {
'& > *': {
margin: theme.spacing(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 />
}
]
2020-12-04 20:16:24 +01:00
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}
src='/logo-192x110.png'
/>
<Typography variant='h6' component='h1'>
Organisation KA Internationale
</Typography>
</Container>
2021-07-19 23:41:59 +02:00
<Container className={classes.root} align='center'>
<RezoMenu data={REZO} />
<Button
startIcon={<HelpIcon style={{fontSize: 25}} />}
size='large'
variant='contained'
color='primary'
onClick={handleClick}
>
Èd
</Button>
</Container>
<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
}
}
}