Files
pawol.nu/pages/index.js
T

136 lines
4.5 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'
import {Button, Container, Grid, Typography, useMediaQuery, Link} from '@material-ui/core'
2021-05-02 14:30:07 +02:00
import HelpIcon from '@material-ui/icons/Help'
import ChatIcon from '@material-ui/icons/Chat'
import GroupAddIcon from '@material-ui/icons/GroupAdd'
2021-05-06 20:28:44 +02:00
import OndemandVideoIcon from '@material-ui/icons/OndemandVideo'
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'
2020-12-04 20:16:24 +01:00
2020-12-18 22:01:47 +01:00
export default function Home({kantiteAwtis, kantiteTeks}) {
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>
<Container style={{marginTop: '1.5em'}}>
<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>
<Container style={{marginBlock: '1.5em'}} align='center'>
<Grid container spacing={2}>
<Grid item xs={12} md={3}>
2021-05-02 14:30:07 +02:00
<Button
2021-06-14 23:30:00 +02:00
startIcon={<HelpIcon size='large' style={{fontSize: 40}} />}
2021-05-02 14:30:07 +02:00
size='small'
variant='contained'
color='primary'
2021-06-14 23:30:00 +02:00
onClick={handleClick}
2021-05-02 14:30:07 +02:00
>
<Typography style={{fontSize: '2em'}} variant='subtitle1' component='span'>
2021-06-14 23:30:00 +02:00
Guide
2021-05-02 14:30:07 +02:00
</Typography>
</Button>
2021-06-14 23:30:00 +02:00
</Grid>
<Grid item xs={12} md={3}>
<Link href='https://pale.o-k-i.net'>
<Button
startIcon={<ChatIcon size='large' style={{fontSize: 40}} />}
size='small'
variant='contained'
color='primary'
>
<Typography style={{fontSize: '2em'}} variant='subtitle1' component='span'>
Palé
</Typography>
</Button>
</Link>
</Grid>
<Grid item xs={12} md={3}>
<Link href='https://gade.o-k-i.net'>
<Button
startIcon={<OndemandVideoIcon size='large' style={{fontSize: 40}} />}
size='small'
variant='contained'
color='primary'
>
<Typography style={{fontSize: '2em'}} variant='subtitle1' component='span'>
Gadé
</Typography>
</Button>
</Link>
</Grid>
<Grid item xs={12} md={3}>
<Link href='https://www.helloasso.com/associations/organisation-ka-internationale/adhesions/adhesion-oki'>
<Button
startIcon={<GroupAddIcon size='large' style={{fontSize: 40}} />}
size='small'
variant='contained'
color='primary'
>
<Typography style={{fontSize: '2em'}} variant='subtitle1' component='span'>
Adhérer
</Typography>
</Button>
</Link>
</Grid>
2021-05-02 14:30:07 +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
}
}
}