From ead6a1ef64ad7eb81da8eada99f7c27f75f26949 Mon Sep 17 00:00:00 2001 From: Hampus Hallkvist Date: Sat, 16 Nov 2024 15:10:27 +0100 Subject: [PATCH] fix: Conditionally hide exhibitor signup and redirect to map during fair --- .../_components/CompanyRegistrationButton.tsx | 12 +++++++++++- src/app/exhibitor/layout.tsx | 13 +++---------- src/app/page.tsx | 19 +++++++++++++++++-- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/app/_components/CompanyRegistrationButton.tsx b/src/app/_components/CompanyRegistrationButton.tsx index 76086c9..b5f74f3 100644 --- a/src/app/_components/CompanyRegistrationButton.tsx +++ b/src/app/_components/CompanyRegistrationButton.tsx @@ -1,7 +1,17 @@ +import { P } from "@/app/_components/Paragraph" +import { fetchDates } from "@/components/shared/hooks/api/useDates" import { Button } from "@/components/ui/button" +import { DateTime } from "luxon" import Link from "next/link" -export function CompanyRegistrationButton() { +export async function CompanyRegistrationButton() { + const { fr } = await fetchDates() + const isAfterFr = DateTime.now() > DateTime.fromISO(fr.end) + + if (isAfterFr) { + return

{DateTime.now().year} signup is closed

+ } + return ( diff --git a/src/app/exhibitor/layout.tsx b/src/app/exhibitor/layout.tsx index 9787469..cd17262 100644 --- a/src/app/exhibitor/layout.tsx +++ b/src/app/exhibitor/layout.tsx @@ -1,23 +1,16 @@ +import { CompanyRegistrationButton } from "@/app/_components/CompanyRegistrationButton" import { CompanySubmissionPopover } from "@/app/exhibitor/_components/CompanySubmissionPopover" import { NavigationMenu } from "@/components/shared/NavigationMenu" -import { Button } from "@/components/ui/button" import { Toaster } from "@/components/ui/sonner" -import Link from "next/link" -export default function ExhibitorLayout({ +export default async function ExhibitorLayout({ children }: Readonly<{ children: React.ReactNode }>) { return ( <> - - - - } - /> + } /> {children} diff --git a/src/app/page.tsx b/src/app/page.tsx index fbf7765..52c7b97 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -6,7 +6,8 @@ import { fetchExhibitors } from "@/components/shared/hooks/api/useExhibitors" import { NavigationMenu } from "@/components/shared/NavigationMenu" import { Page } from "@/components/shared/Page" import { Button } from "@/components/ui/button" -import { ArrowRightIcon } from "lucide-react" +import { ArrowRightIcon, MapIcon } from "lucide-react" +import { DateTime } from "luxon" import Image from "next/image" import Link from "next/link" import { Suspense } from "react" @@ -26,12 +27,26 @@ export default async function HomePage() { exhibitor => exhibitor.name === "Nordea" ) + const isAfterFr = DateTime.now() > DateTime.fromISO(dates.fr.end) + return ( <> {today < fr_end ? ( ) : ( - } /> + + + + ) : ( + + ) + } + /> )}