Replace DenyeTeks by stats in home
This commit is contained in:
+17
-13
@@ -1,16 +1,17 @@
|
||||
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 HeadLayout from '../components/head-layout'
|
||||
import Footer from '../components/footer'
|
||||
import RezoDialog from '../components/rezo/rezo-dialog'
|
||||
import DenyeTeks from '../components/teks/denye-teks'
|
||||
import {jwennDenyeTeks} from '../lib/oki-api'
|
||||
import {jwennStats} from '../lib/oki-api'
|
||||
|
||||
import KatKayLa from '../components/kat-kay-la'
|
||||
|
||||
import Custom500 from './500'
|
||||
|
||||
export default function Home({errorCode, errorMessage, teks}) {
|
||||
export default function Home({errorCode, errorMessage, stats}) {
|
||||
if (errorCode) {
|
||||
console.log('⚠️ error', errorMessage)
|
||||
return <Custom500 statusCode={errorCode} />
|
||||
@@ -19,7 +20,7 @@ export default function Home({errorCode, errorMessage, teks}) {
|
||||
return (
|
||||
<HeadLayout tab={0}>
|
||||
<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'>
|
||||
<Typography sx={{fontWeight: 'bold'}} variant='h6' component='h1'>
|
||||
#OKi
|
||||
@@ -36,10 +37,13 @@ export default function Home({errorCode, errorMessage, teks}) {
|
||||
</Container>
|
||||
</Box>
|
||||
<Container sx={{flexGrow: 100}}>
|
||||
<Divider variant='middle' sx={{marginBottom: 1}}>
|
||||
<Chip sx={{fontWeight: 'bold'}} color='primary' icon={<ArrowCircleDownIcon />} label='Derniers textes publiés ' variant='outlined' />
|
||||
<Divider sx={{marginBottom: 3}}>
|
||||
<Chip sx={{fontWeight: 'bold'}} color='primary' icon={<ArrowCircleDownIcon />} label='Statistiques' variant='outlined' />
|
||||
</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>
|
||||
<Footer />
|
||||
</Box>
|
||||
@@ -48,12 +52,12 @@ export default function Home({errorCode, errorMessage, teks}) {
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
let denyeTeks
|
||||
let stats
|
||||
let errorCode
|
||||
let errorMessage
|
||||
|
||||
try {
|
||||
denyeTeks = await jwennDenyeTeks()
|
||||
stats = await jwennStats()
|
||||
} catch (error) {
|
||||
errorMessage = error.message
|
||||
errorCode = true
|
||||
@@ -63,7 +67,7 @@ export async function getServerSideProps() {
|
||||
props: {
|
||||
errorCode: errorCode || null,
|
||||
errorMessage: errorMessage || null,
|
||||
teks: denyeTeks || null
|
||||
stats: stats || null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,11 +75,11 @@ export async function getServerSideProps() {
|
||||
Home.defaultProps = {
|
||||
errorCode: null,
|
||||
errorMessage: null,
|
||||
teks: null
|
||||
stats: null
|
||||
}
|
||||
|
||||
Home.propTypes = {
|
||||
errorCode: PropTypes.bool,
|
||||
errorMessage: PropTypes.string,
|
||||
teks: PropTypes.array
|
||||
stats: PropTypes.object
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user