From e1f3b83ce98cb8761e8ca0f0b01d7765e7220bb9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 6 Jun 2022 02:10:04 +0200 Subject: [PATCH] Improve event view --- components/view/ViewEvent.tsx | 24 ++++++++++++++++++++++++ pages/events/[slug].tsx | 29 ++++++++++++++++++++--------- public/locales/it-IT/common.json | 7 +++++-- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 components/view/ViewEvent.tsx diff --git a/components/view/ViewEvent.tsx b/components/view/ViewEvent.tsx new file mode 100644 index 0000000..4dd47e3 --- /dev/null +++ b/components/view/ViewEvent.tsx @@ -0,0 +1,24 @@ +import { ReactNode } from "react" + +type ViewEventProps = { + title: ReactNode + postcard: ReactNode + description: ReactNode +} + + +export function ViewEvent(props: ViewEventProps) { + return ( +
+

+ {props.title} +

+
+ {props.postcard} +
+
+ {props.description} +
+
+ ) +} \ No newline at end of file diff --git a/pages/events/[slug].tsx b/pages/events/[slug].tsx index 5334eac..3c22303 100644 --- a/pages/events/[slug].tsx +++ b/pages/events/[slug].tsx @@ -13,6 +13,7 @@ import { database } from "../../utils/prismaClient"; import { Postcard } from "../../components/postcard/Postcard"; import { ViewContent } from "../../components/view/ViewContent"; import { EditablePostcard } from "../../components/editable/EditablePostcard"; +import { ViewEvent } from "../../components/view/ViewEvent"; export async function getServerSideProps(context: NextPageContext) { @@ -46,6 +47,7 @@ type PageEventDetailProps = { export default function PageEventDetail({event}: PageEventDetailProps) { const {t} = useTranslation() const editState = useState(false) + const [title, setTitle] = useState(event.name) const [description, setDescription] = useState(event.description) const [postcard, setPostcard] = useState(event.postcard) @@ -69,23 +71,32 @@ export default function PageEventDetail({event}: PageEventDetailProps) { {event.name} - {t("siteTitle")} - + - - } - content={<> - setDescription((e.target as HTMLTextAreaElement).value)} + ) => setTitle(e.target.value)} + placeholder={t("eventDetailsTitlePlaceholder")} /> + } + postcard={ - } + } + description={ + ) => setDescription(e.target.value)} + rows={3} + placeholder={t("eventDetailsDescriptionPlaceholder")} + /> + } /> diff --git a/public/locales/it-IT/common.json b/public/locales/it-IT/common.json index 5afbdf6..09c5890 100644 --- a/public/locales/it-IT/common.json +++ b/public/locales/it-IT/common.json @@ -26,6 +26,9 @@ "eventListCreateRunning": "Creazione in corso...", "eventListCreateRedirecting": "Caricamento dell'evento in corso...", "eventListCreateError": "Si รจ verificato il seguente errore nella creazione del tuo evento:", - "toggleEditingEdit": "Modifica pagina", - "toggleEditingView": "Visualizza anteprima" + "eventDetailsToggleEditingEdit": "Modifica pagina", + "eventDetailsToggleEditingView": "Visualizza anteprima", + "eventDetailsTitlePlaceholder": "Titolo", + "eventDetailsDescriptionPlaceholder": "Descrizione evento", + "eventDetailsPostcardPlaceholder": "Cartolina" }