Skip to content

Commit

Permalink
fix: Conditionally hide exhibitor signup and redirect to map during fair
Browse files Browse the repository at this point in the history
  • Loading branch information
hampfh committed Nov 16, 2024
1 parent 836868e commit ead6a1e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
12 changes: 11 additions & 1 deletion src/app/_components/CompanyRegistrationButton.tsx
Original file line number Diff line number Diff line change
@@ -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 <P>{DateTime.now().year} signup is closed</P>
}

return (
<Link href="https://register.armada.nu/register">
<Button>Exhibitor Signup</Button>
Expand Down
13 changes: 3 additions & 10 deletions src/app/exhibitor/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<NavigationMenu
aside={
<Link href="https://register.armada.nu/register">
<Button>Exhibitor signup</Button>
</Link>
}
/>
<NavigationMenu aside={<CompanyRegistrationButton />} />
{children}
<CompanySubmissionPopover />
<Toaster expand={true} richColors closeButton />
Expand Down
19 changes: 17 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ? (
<NavigationMenu />
) : (
<NavigationMenu aside={<CompanyRegistrationButton />} />
<NavigationMenu
aside={
isAfterFr ? (
<Link href={"/student/map"}>
<Button className="flex gap-2">
<MapIcon size={15} /> Visit the map
</Button>
</Link>
) : (
<CompanyRegistrationButton />
)
}
/>
)}

<Page.Background className="">
Expand Down

0 comments on commit ead6a1e

Please sign in to comment.