diff --git a/app/[locale]/(root)/calendar/[id]/page.tsx b/app/[locale]/(root)/calendar/[id]/page.tsx index 75d9c3a..7f5b7b0 100644 --- a/app/[locale]/(root)/calendar/[id]/page.tsx +++ b/app/[locale]/(root)/calendar/[id]/page.tsx @@ -62,12 +62,15 @@ export default async function EventPage({ )} - + + {data?.url_detailed || data?.url_registration || data?.url_web || data?.web_site ? ( + + ) : null}
-
+ {data?.description ??

{t("description")}

-

{data?.description}

-
+

{data.description}

+
} - {data?.event_topic && ( + {/* {data?.event_topic && ( <>
@@ -101,7 +104,7 @@ export default async function EventPage({ />
- )} + )} */} ); diff --git a/app/[locale]/(root)/calendar/page.tsx b/app/[locale]/(root)/calendar/page.tsx index 7df663d..2b92ad9 100644 --- a/app/[locale]/(root)/calendar/page.tsx +++ b/app/[locale]/(root)/calendar/page.tsx @@ -26,7 +26,7 @@ export default async function CalendarPage() {
{data.data.map((item, i) => ( - + ))}
diff --git a/components/shared/event-card.tsx b/components/shared/event-card.tsx index 32e9dca..75cef40 100644 --- a/components/shared/event-card.tsx +++ b/components/shared/event-card.tsx @@ -16,8 +16,8 @@ import { Link } from "@/i18n/navigation"; interface Props { id: number; description: string; - starts_at: string; - ends_at: string; + starts_at: string | null; + ends_at: string | null; date: string; title: string; web_site: string | null; @@ -44,13 +44,15 @@ export const EventCard = ({ images, dark = false, }: Props) => { - const formatDate = (dateString: string) => { - const dateParts = dateString?.split(" "); - const date = dateParts?.[0]; - const parts = date?.split("-"); - const formattedDate = `${parts?.[2]}.${parts?.[1]}.${parts?.[0]}`; - - return formattedDate; + const formatDate = (dateString: string | null) => { + if (!dateString) return null; + const dateParts = dateString.split(" "); + const date = dateParts[0]; + const parts = date.split("-"); + if (parts.length === 3 && parts[0].length === 4) { + return `${parts[2]}.${parts[1]}.${parts[0]}`; + } + return dateString; }; const t = useTranslations("events"); @@ -80,8 +82,8 @@ export const EventCard = ({ {} )} > -

{formatDate(starts_at)}

{" "} -

{formatDate(ends_at)}

+ {formatDate(starts_at) &&

{formatDate(starts_at)}

} + {formatDate(ends_at) &&

{formatDate(ends_at)}

} @@ -101,20 +103,22 @@ export const EventCard = ({

{title}

-
-

- {t("organiserLabel")} -

-

- {organizers ? organizers[0]?.name : null} -

-
+ {organizers && organizers?.length > 0 && +
+

+ {t("organiserLabel")} +

+

+ {organizers ? organizers[0]?.name : null} +

+
+ } {coorganizers && coorganizers?.length > 0 && (

@@ -128,8 +132,8 @@ export const EventCard = ({

-

{formatDate(starts_at)}

{" "} -

{formatDate(ends_at)}

+ {formatDate(starts_at) &&

{formatDate(starts_at)}

} + {formatDate(ends_at) &&

{formatDate(ends_at)}

}
diff --git a/components/shared/event-page-buttons.tsx b/components/shared/event-page-buttons.tsx index 04b8191..2bdedd2 100644 --- a/components/shared/event-page-buttons.tsx +++ b/components/shared/event-page-buttons.tsx @@ -1,7 +1,6 @@ "use client"; import { useTranslations } from "next-intl"; -import { Link } from "@/i18n/navigation"; import { FC } from "react"; interface Props { @@ -12,6 +11,11 @@ interface Props { details?: string; } +function toExternalUrl(url: string) { + if (!/^https?:\/\//i.test(url)) return `https://${url}`; + return url; +} + export const EventPageButtons: FC = ({ once = false, register, @@ -24,23 +28,23 @@ export const EventPageButtons: FC = ({
{once ? ( <> - + - - + + - + ) : ( - + - + )}
); diff --git a/lib/types/Calendar.type.ts b/lib/types/Calendar.type.ts index bbf7d89..d9fc7c3 100644 --- a/lib/types/Calendar.type.ts +++ b/lib/types/Calendar.type.ts @@ -22,6 +22,8 @@ export interface EventDatum { installation_date: string; dismantling_date: string; event_topic: string; + starts_at_text: string | null + ends_at_text: string | null } export interface Coorganizers {