mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 22:54:22 +00:00
Improve event view
This commit is contained in:
parent
b92c123c38
commit
e1f3b83ce9
3 changed files with 49 additions and 11 deletions
24
components/view/ViewEvent.tsx
Normal file
24
components/view/ViewEvent.tsx
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import { ReactNode } from "react"
|
||||||
|
|
||||||
|
type ViewEventProps = {
|
||||||
|
title: ReactNode
|
||||||
|
postcard: ReactNode
|
||||||
|
description: ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function ViewEvent(props: ViewEventProps) {
|
||||||
|
return (
|
||||||
|
<main className="view-event">
|
||||||
|
<h1 className="view-event-title">
|
||||||
|
{props.title}
|
||||||
|
</h1>
|
||||||
|
<div className="view-event-postcard">
|
||||||
|
{props.postcard}
|
||||||
|
</div>
|
||||||
|
<div className="view-event-description">
|
||||||
|
{props.description}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ import { database } from "../../utils/prismaClient";
|
||||||
import { Postcard } from "../../components/postcard/Postcard";
|
import { Postcard } from "../../components/postcard/Postcard";
|
||||||
import { ViewContent } from "../../components/view/ViewContent";
|
import { ViewContent } from "../../components/view/ViewContent";
|
||||||
import { EditablePostcard } from "../../components/editable/EditablePostcard";
|
import { EditablePostcard } from "../../components/editable/EditablePostcard";
|
||||||
|
import { ViewEvent } from "../../components/view/ViewEvent";
|
||||||
|
|
||||||
|
|
||||||
export async function getServerSideProps(context: NextPageContext) {
|
export async function getServerSideProps(context: NextPageContext) {
|
||||||
|
@ -46,6 +47,7 @@ type PageEventDetailProps = {
|
||||||
export default function PageEventDetail({event}: PageEventDetailProps) {
|
export default function PageEventDetail({event}: PageEventDetailProps) {
|
||||||
const {t} = useTranslation()
|
const {t} = useTranslation()
|
||||||
const editState = useState<boolean>(false)
|
const editState = useState<boolean>(false)
|
||||||
|
const [title, setTitle] = useState<string>(event.name)
|
||||||
const [description, setDescription] = useState<string>(event.description)
|
const [description, setDescription] = useState<string>(event.description)
|
||||||
const [postcard, setPostcard] = useState<string | null>(event.postcard)
|
const [postcard, setPostcard] = useState<string | null>(event.postcard)
|
||||||
|
|
||||||
|
@ -69,23 +71,32 @@ export default function PageEventDetail({event}: PageEventDetailProps) {
|
||||||
<title key="title">{event.name} - {t("siteTitle")}</title>
|
<title key="title">{event.name} - {t("siteTitle")}</title>
|
||||||
</Head>
|
</Head>
|
||||||
<EditingContext.Provider value={editState}>
|
<EditingContext.Provider value={editState}>
|
||||||
<ToolBar vertical="top" horizontal="right">
|
<ToolBar vertical="bottom" horizontal="right">
|
||||||
<ToolToggleEditing/>
|
<ToolToggleEditing/>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ViewContent
|
<ViewEvent
|
||||||
title={
|
title={
|
||||||
<EditableText value={event.name}/>
|
<EditableText
|
||||||
}
|
value={title}
|
||||||
content={<>
|
onChange={(e: ChangeEvent<HTMLInputElement>) => setTitle(e.target.value)}
|
||||||
<EditableMarkdown
|
placeholder={t("eventDetailsTitlePlaceholder")}
|
||||||
value={description}
|
|
||||||
onChange={e => setDescription((e.target as HTMLTextAreaElement).value)}
|
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
|
postcard={
|
||||||
<EditablePostcard
|
<EditablePostcard
|
||||||
value={postcard ?? undefined}
|
value={postcard ?? undefined}
|
||||||
onChange={setPostcardBlob}
|
onChange={setPostcardBlob}
|
||||||
|
placeholder={t("eventDetailsPostcardPlaceholder")}
|
||||||
/>
|
/>
|
||||||
</>}
|
}
|
||||||
|
description={
|
||||||
|
<EditableMarkdown
|
||||||
|
value={description}
|
||||||
|
onChange={(e: ChangeEvent<HTMLTextAreaElement>) => setDescription(e.target.value)}
|
||||||
|
rows={3}
|
||||||
|
placeholder={t("eventDetailsDescriptionPlaceholder")}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</EditingContext.Provider>
|
</EditingContext.Provider>
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
"eventListCreateRunning": "Creazione in corso...",
|
"eventListCreateRunning": "Creazione in corso...",
|
||||||
"eventListCreateRedirecting": "Caricamento dell'evento in corso...",
|
"eventListCreateRedirecting": "Caricamento dell'evento in corso...",
|
||||||
"eventListCreateError": "Si è verificato il seguente errore nella creazione del tuo evento:",
|
"eventListCreateError": "Si è verificato il seguente errore nella creazione del tuo evento:",
|
||||||
"toggleEditingEdit": "Modifica pagina",
|
"eventDetailsToggleEditingEdit": "Modifica pagina",
|
||||||
"toggleEditingView": "Visualizza anteprima"
|
"eventDetailsToggleEditingView": "Visualizza anteprima",
|
||||||
|
"eventDetailsTitlePlaceholder": "Titolo",
|
||||||
|
"eventDetailsDescriptionPlaceholder": "Descrizione evento",
|
||||||
|
"eventDetailsPostcardPlaceholder": "Cartolina"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue