1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-22 14:44:21 +00:00

Add something to the event page

This commit is contained in:
Steffo 2022-07-16 18:18:41 +02:00
parent 9e7bdadc3e
commit 5105ea9045
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -7,6 +7,13 @@ import { Postcard } from '../../components/postcard/changer'
import { ViewEvent } from '../../components/events/views/event'
import useSWR from 'swr'
import { Event } from '@prisma/client'
import { EditableText } from '../../components/generic/editable/inputs'
import { EditingContext, EditingMode } from '../../components/generic/editable/base'
import { useState } from 'react'
import { ToolBar } from '../../components/generic/toolbar/bar'
import { ToolToggleEditing } from '../../components/events/toolbar/toolToggleEditing'
import { ToolToggleVisibility } from '../../components/postcard/toolbar/toolToggleVisibility'
import { WIPBanner } from '../../components/generic/wip/banner'
export async function getServerSideProps(context: NextPageContext) {
@ -28,20 +35,40 @@ const PageEvent: NextPage<PageEventProps> = ({ slug }) => {
const { t } = useTranslation()
const { data, error } = useSWR<Event>(`/api/events/${slug}`)
const displayTitle = data?.name ?? slug
const displayPostcard = data?.postcard ?? defaultPostcard
const displayDescription = data?.description ?? ""
return <>
<Head>
<title key="title">eventName - {t("siteTitle")}</title>
<title key="title">{displayTitle} - {t("siteTitle")}</title>
<link rel="preload" href={`/api/events/${slug}`} as="fetch" />
</Head>
<Postcard
src={data?.postcard ?? defaultPostcard}
src={displayPostcard}
/>
<WIPBanner />
<EditingContext.Provider value={useState<EditingMode>(EditingMode.VIEW)}>
<ViewEvent
title={<>{data?.name ?? slug}</>}
title={<>
<EditableText
value={displayTitle}
/>
</>}
postcard={<></>}
description={<>{data?.description}</>}
description={<>
<EditableText
value={displayDescription}
/>
</>}
daterange={<></>}
/>
<ToolBar vertical="vadapt" horizontal="right">
<ToolToggleEditing />
<ToolToggleVisibility />
</ToolBar>
</EditingContext.Provider>
</>
}