Add komante to TeksDrawer

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2021-06-26 12:17:54 +02:00
parent 4ff88ebb61
commit 72651a660b
+10 -5
View File
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import {jwennTeksEpiSlug, jwennTeks} from '../../lib/oki-api' import {jwennTeksEpiSlug, jwennTeks, jwennKomanteEpiTeksId} from '../../lib/oki-api'
import TeksDrawer from '../../components/teks/teks-drawer' import TeksDrawer from '../../components/teks/teks-drawer'
import HeadLayout from '../../components/head-layout' import HeadLayout from '../../components/head-layout'
@@ -9,7 +9,7 @@ const jwennAwtis = awtis => {
return awtis.map(a => a.alias).join(', ') return awtis.map(a => a.alias).join(', ')
} }
export default function SlugTeks({teks, anTeks, slug}) { export default function SlugTeks({teks, anTeks, slug, komante}) {
const awtis = anTeks.awtis.length === 1 ? anTeks.awtis[0].alias : jwennAwtis(anTeks.awtis) const awtis = anTeks.awtis.length === 1 ? anTeks.awtis[0].alias : jwennAwtis(anTeks.awtis)
const {kouveti} = anTeks const {kouveti} = anTeks
const formatKouveti = () => { const formatKouveti = () => {
@@ -40,7 +40,7 @@ export default function SlugTeks({teks, anTeks, slug}) {
imageMime={formatKouveti() ? formatKouveti().mime : null} imageMime={formatKouveti() ? formatKouveti().mime : null}
title={`${awtis} - ${anTeks.tit}`} tab={2} slug={`teks/${slug}`} title={`${awtis} - ${anTeks.tit}`} tab={2} slug={`teks/${slug}`}
> >
<TeksDrawer teks={teks} anTeks={anTeks} /> <TeksDrawer teks={teks} anTeks={anTeks} komante={komante} />
</HeadLayout> </HeadLayout>
) )
} }
@@ -54,11 +54,15 @@ export async function getServerSideProps({query}) {
throw new Error('San répons') throw new Error('San répons')
} }
const {_id} = anTeks
const komante = await jwennKomanteEpiTeksId(_id)
return { return {
props: { props: {
teks, teks,
anTeks, anTeks,
slug slug,
komante
} }
} }
} }
@@ -66,5 +70,6 @@ export async function getServerSideProps({query}) {
SlugTeks.propTypes = { SlugTeks.propTypes = {
teks: PropTypes.array.isRequired, teks: PropTypes.array.isRequired,
anTeks: PropTypes.object.isRequired, anTeks: PropTypes.object.isRequired,
slug: PropTypes.string.isRequired slug: PropTypes.string.isRequired,
komante: PropTypes.array.isRequired
} }