Files
pawol.nu/pages/index.js
T

91 lines
2.7 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'
2020-12-11 01:38:05 +01:00
import axios from 'axios'
2020-12-17 22:36:27 +01:00
import TouchAppIcon from '@material-ui/icons/TouchApp'
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'
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 = [
{id: 1, tit: 'Kantité Awtis', kantite: kantiteAwtis, route: '/awtis?paj&paj=1'},
{id: 2, tit: 'Kantité Tèks', kantite: kantiteTeks, route: '/teks'}
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}>
2020-12-17 22:36:27 +01:00
<Container align='center'>
<Image
alt='Logo #OKi'
2020-12-22 23:14:54 +01:00
width={384}
height={220}
src='/logo-384x220.png'
2020-12-17 22:36:27 +01:00
/>
2020-12-18 22:01:47 +01:00
<Typography variant='h3' component='h1'>
2020-12-17 22:36:27 +01:00
Organisation KA Internationale
</Typography>
<Typography variant='h4' component='h2' color='textSecondary'>
Transcriptions et traductions
</Typography>
<Typography variant='h5' component='h2'>
<Link href='mailto:kontak@o-k-i.net'>
kontak@o-k-i.net
</Link>
</Typography>
</Container>
<Container style={{marginTop: '5em'}}>
<Grid container spacing={3}>
2020-12-18 22:01:47 +01:00
{kantite.map(k => <KatKayLa key={k.id} tit={k.tit} kantite={k.kantite} route={k.route} />)}
2020-12-17 22:36:27 +01:00
</Grid>
</Container>
<Container style={{marginTop: '5em', marginBottom: '5em'}} align='center'>
<Button
startIcon={<TouchAppIcon size='large' style={{fontSize: 50}} />}
size='large'
variant='contained'
color='primary'
onClick={handleClick}
>
<Typography style={{fontSize: '2em'}} variant='subtitle1' component='span'>
Guide
</Typography>
</Button>
</Container>
2020-12-17 09:08:18 +01:00
<Carousel
isMobile={matches}
handleOpen={handleOpen}
setHandleOpen={setHandleOpen}
/>
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() {
2020-12-17 22:36:27 +01:00
const awtisResponse = await axios.get(`${process.env.API_URL}/awtis/count`)
2020-12-18 21:58:12 +01:00
const teksResponse = await axios.get(`${process.env.API_URL}/teks/count`)
2020-12-18 22:01:47 +01:00
const kantiteAwtis = awtisResponse.data
const kantiteTeks = teksResponse.data
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
}
}
}