Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/frontend/src/components/ThemeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function ThemeToggle() {
onClick={toggleMode}
aria-label={label}
title={label}
className="rounded-full bg-[var(--cream-dark)] px-3 py-1.5 text-sm font-semibold text-[var(--stout-black)] shadow-[0_8px_22px_rgba(30,90,72,0.08)] transition hover:-translate-y-0.5"
className="rounded-full bg-(--cream-dark) px-3 py-1.5 text-sm font-semibold text-(--stout-black) shadow-[0_8px_22px_rgba(30,90,72,0.08)] transition hover:-translate-y-0.5"
>
{mode === 'dark' ? 'Dark' : 'Light'}
</button>
Expand Down
51 changes: 42 additions & 9 deletions apps/frontend/src/components/ViewVenue.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,64 @@
import type { venue } from '#/types/venue'
import { useQuery } from '@tanstack/react-query'
import { graphqlFetch } from '#/graphql/client'

export default function ViewVenue(Current: venue) {
const GET_VENUE = `
query GetVenues {
venue {
id
name
address
city {
id
name
}
openingHours {
days
opening
closing
}
}
}
`

export function ViewVenue(Current: venue) {
const fmt = (iso: string) => iso.slice(11, 16)

return (
<article className="rounded-2xl border border-[var(--harp-gold)] bg-[var(--cream)] p-5 text-[var(--sea-ink)]">
<p className="text-xs font-bold tracking-widest uppercase text-[var(--)]">
<article className="rounded-2xl border border-(--harp-gold) bg-(--cream) p-5 text-(--sea-ink)">
<p className="text-xs font-bold tracking-widest uppercase text-(--)">
{Current.city.name}
</p>
<h2 className="mt-1 text-xl font-extrabold">{Current.name}</h2>
<p className="mt-1 text-sm text-[var(--sea-ink-soft)]">
{Current.address}
</p>
<p className="mt-1 text-sm text-(--sea-ink-soft)">{Current.address}</p>
<h3 className="mt-4 text-sm font-bold">Opening hours</h3>
<ul className="mt-1">
{Current.openingHours.map((oh, i) => (
<li
key={i}
className="flex items-baseline justify-between gap-4 border-t border-[var(--line)] py-2 text-sm"
className="flex items-baseline justify-between gap-4 border-t border-(--line) py-2 text-sm"
>
<span className="font-semibold">{oh.days.join(', ')}</span>
<span className="text-[var(--sea-ink-soft)]">
{fmt(oh.opening)} – {fmt(oh.closing)}
<span className="text-(--sea-ink-soft)">
{fmt(oh.opening)} - {fmt(oh.closing)}
</span>
</li>
))}
</ul>
</article>
)
}

export default function VenueLoader() {
const { data, isPending, isError } = useQuery({
queryKey: ['venues'],
queryFn: () => graphqlFetch<{ venue: venue[] }>(GET_VENUE),
})

if (isPending) return <p>Loading venue…</p>
if (isError) return <div>error</div>
// Hardcoded: show first venue for now
if (data.venue.length == 0) return <div>No venues found</div>
const first = data.venue[0]
return <ViewVenue {...first} />
}
41 changes: 2 additions & 39 deletions apps/frontend/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import TanStackQueryDevtools from '../integrations/tanstack-query/devtools'
import appCss from '../styles.css?url'

import type { QueryClient } from '@tanstack/react-query'
import { useQuery } from '@tanstack/react-query'
import ViewVenue from '#/components/ViewVenue'
import { graphqlFetch } from '#/graphql/client'
import type { venue } from '#/types/venue'

interface MyRouterContext {
queryClient: QueryClient
Expand Down Expand Up @@ -48,39 +44,6 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
shellComponent: RootDocument,
})

const GET_VENUE = `
query GetVenues {
venue {
id
name
address
city {
id
name
}
openingHours {
days
opening
closing
}
}
}
`

function VenueLoader() {
const { data, isPending, isError } = useQuery({
queryKey: ['venues'],
queryFn: () => graphqlFetch<{ venue: venue[] }>(GET_VENUE),
})

if (isPending) return <p>Loading venue…</p>
if (isError) return <div>error</div>
// Hardcoded: show first venue for now
if (data.venue.length == 0) return <div>No venues found</div>
const first = data.venue[0]
return <ViewVenue {...first} />
}

function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
Expand All @@ -94,10 +57,10 @@ function RootDocument({ children }: { children: React.ReactNode }) {
/>
<HeadContent />
</head>
<body className="font-sans antialiased [overflow-wrap:anywhere] selection:bg-[rgba(79,184,178,0.24)]">
<body className="font-sans antialiased wrap-anywhere selection:bg-[rgba(79,184,178,0.24)]">
<Header />
{children}
<VenueLoader />

<Footer />
<TanStackDevtools
config={{
Expand Down
4 changes: 3 additions & 1 deletion apps/frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { createFileRoute } from '@tanstack/react-router'
import Map from '../components/Map'
import VenueLoader from '#/components/ViewVenue'

export const Route = createFileRoute('/')({ component: App })

function App() {
return (
<main className="page-wrap px-4 pb-8 pt-14">
<section className="island-shell rise-in relative overflow-hidden rounded-[2rem] px-6 py-10 sm:px-10 sm:py-14">
<section className="island-shell rise-in relative overflow-hidden rounded-4xl px-6 py-10 sm:px-10 sm:py-14 mb-10">
<Map />
</section>
<VenueLoader />
</main>
)
}