Replace DenyeTeks by stats in home
This commit is contained in:
+17
-13
@@ -1,16 +1,17 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import {Container, Typography, Box, Divider, Chip} from '@mui/material'
|
import {Container, Typography, Box, Divider, Chip, Grid} from '@mui/material'
|
||||||
import ArrowCircleDownIcon from '@mui/icons-material/ArrowCircleDown'
|
import ArrowCircleDownIcon from '@mui/icons-material/ArrowCircleDown'
|
||||||
|
|
||||||
import HeadLayout from '../components/head-layout'
|
import HeadLayout from '../components/head-layout'
|
||||||
import Footer from '../components/footer'
|
import Footer from '../components/footer'
|
||||||
import RezoDialog from '../components/rezo/rezo-dialog'
|
import RezoDialog from '../components/rezo/rezo-dialog'
|
||||||
import DenyeTeks from '../components/teks/denye-teks'
|
import {jwennStats} from '../lib/oki-api'
|
||||||
import {jwennDenyeTeks} from '../lib/oki-api'
|
|
||||||
|
import KatKayLa from '../components/kat-kay-la'
|
||||||
|
|
||||||
import Custom500 from './500'
|
import Custom500 from './500'
|
||||||
|
|
||||||
export default function Home({errorCode, errorMessage, teks}) {
|
export default function Home({errorCode, errorMessage, stats}) {
|
||||||
if (errorCode) {
|
if (errorCode) {
|
||||||
console.log('⚠️ error', errorMessage)
|
console.log('⚠️ error', errorMessage)
|
||||||
return <Custom500 statusCode={errorCode} />
|
return <Custom500 statusCode={errorCode} />
|
||||||
@@ -19,7 +20,7 @@ export default function Home({errorCode, errorMessage, teks}) {
|
|||||||
return (
|
return (
|
||||||
<HeadLayout tab={0}>
|
<HeadLayout tab={0}>
|
||||||
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
|
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
|
||||||
<Box sx={{flexGrow: 1, marginBottom: 4}}>
|
<Box sx={{flexGrow: 1, marginBottom: 3, marginTop: 1}}>
|
||||||
<Container sx={{marginBottom: 2}} align='center'>
|
<Container sx={{marginBottom: 2}} align='center'>
|
||||||
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h1'>
|
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h1'>
|
||||||
#OKi
|
#OKi
|
||||||
@@ -36,10 +37,13 @@ export default function Home({errorCode, errorMessage, teks}) {
|
|||||||
</Container>
|
</Container>
|
||||||
</Box>
|
</Box>
|
||||||
<Container sx={{flexGrow: 100}}>
|
<Container sx={{flexGrow: 100}}>
|
||||||
<Divider variant='middle' sx={{marginBottom: 1}}>
|
<Divider sx={{marginBottom: 3}}>
|
||||||
<Chip sx={{fontWeight: 'bold'}} color='primary' icon={<ArrowCircleDownIcon />} label='Derniers textes publiés ' variant='outlined' />
|
<Chip sx={{fontWeight: 'bold'}} color='primary' icon={<ArrowCircleDownIcon />} label='Statistiques' variant='outlined' />
|
||||||
</Divider>
|
</Divider>
|
||||||
<DenyeTeks denyeTeks={teks} />
|
<Grid container spacing={2} sx={{marginBottom: 3}}>
|
||||||
|
<KatKayLa tit='Textes' kantite={stats.countParole} href='/paroles' as='/paroles' />
|
||||||
|
<KatKayLa tit='Artistes' kantite={stats.countArtiste} href='/awtis?paj&paj=1' as='/awtis/paj/1' />
|
||||||
|
</Grid>
|
||||||
</Container>
|
</Container>
|
||||||
<Footer />
|
<Footer />
|
||||||
</Box>
|
</Box>
|
||||||
@@ -48,12 +52,12 @@ export default function Home({errorCode, errorMessage, teks}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getServerSideProps() {
|
export async function getServerSideProps() {
|
||||||
let denyeTeks
|
let stats
|
||||||
let errorCode
|
let errorCode
|
||||||
let errorMessage
|
let errorMessage
|
||||||
|
|
||||||
try {
|
try {
|
||||||
denyeTeks = await jwennDenyeTeks()
|
stats = await jwennStats()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorMessage = error.message
|
errorMessage = error.message
|
||||||
errorCode = true
|
errorCode = true
|
||||||
@@ -63,7 +67,7 @@ export async function getServerSideProps() {
|
|||||||
props: {
|
props: {
|
||||||
errorCode: errorCode || null,
|
errorCode: errorCode || null,
|
||||||
errorMessage: errorMessage || null,
|
errorMessage: errorMessage || null,
|
||||||
teks: denyeTeks || null
|
stats: stats || null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,11 +75,11 @@ export async function getServerSideProps() {
|
|||||||
Home.defaultProps = {
|
Home.defaultProps = {
|
||||||
errorCode: null,
|
errorCode: null,
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
teks: null
|
stats: null
|
||||||
}
|
}
|
||||||
|
|
||||||
Home.propTypes = {
|
Home.propTypes = {
|
||||||
errorCode: PropTypes.bool,
|
errorCode: PropTypes.bool,
|
||||||
errorMessage: PropTypes.string,
|
errorMessage: PropTypes.string,
|
||||||
teks: PropTypes.array
|
stats: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user