Phase 3 - Frontend Multi-Vertical Support: - Add VerticalContext for band state management - Add BandSelector dropdown component - Create dynamic [vertical] routes for shows, songs, venues - Update navbar to use band selector and vertical-aware links - Update api-config.ts for Fediversion domain - Rebrand from Elmeg to Fediversion
76 lines
2.7 KiB
TypeScript
76 lines
2.7 KiB
TypeScript
import { VERTICALS } from "@/contexts/vertical-context"
|
|
import { notFound } from "next/navigation"
|
|
import { getApiUrl } from "@/lib/api-config"
|
|
|
|
interface Props {
|
|
params: { vertical: string }
|
|
}
|
|
|
|
export function generateStaticParams() {
|
|
return VERTICALS.map((v) => ({
|
|
vertical: v.slug,
|
|
}))
|
|
}
|
|
|
|
async function getShows(verticalSlug: string) {
|
|
try {
|
|
const res = await fetch(`${getApiUrl()}/shows?vertical=${verticalSlug}`, {
|
|
next: { revalidate: 60 }
|
|
})
|
|
if (!res.ok) return []
|
|
return res.json()
|
|
} catch {
|
|
return []
|
|
}
|
|
}
|
|
|
|
export default async function ShowsPage({ params }: Props) {
|
|
const vertical = VERTICALS.find((v) => v.slug === params.vertical)
|
|
|
|
if (!vertical) {
|
|
notFound()
|
|
}
|
|
|
|
const shows = await getShows(vertical.slug)
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
<div className="flex items-center justify-between">
|
|
<h1 className="text-3xl font-bold">
|
|
<span className="mr-2">{vertical.emoji}</span>
|
|
{vertical.name} Shows
|
|
</h1>
|
|
</div>
|
|
|
|
{shows.length === 0 ? (
|
|
<div className="text-center py-12 text-muted-foreground">
|
|
<p>No shows imported yet for {vertical.name}.</p>
|
|
<p className="text-sm mt-2">Run the data importer to populate shows.</p>
|
|
</div>
|
|
) : (
|
|
<div className="space-y-4">
|
|
{shows.map((show: any) => (
|
|
<a
|
|
key={show.id}
|
|
href={`/${vertical.slug}/shows/${show.slug}`}
|
|
className="block p-4 rounded-lg border bg-card hover:bg-accent transition-colors"
|
|
>
|
|
<div className="flex justify-between items-start">
|
|
<div>
|
|
<div className="font-semibold">{show.venue?.name || "Unknown Venue"}</div>
|
|
<div className="text-sm text-muted-foreground">
|
|
{show.venue?.city}, {show.venue?.state || show.venue?.country}
|
|
</div>
|
|
</div>
|
|
<div className="text-right">
|
|
<div className="font-mono">{new Date(show.date).toLocaleDateString()}</div>
|
|
<div className="text-sm text-muted-foreground">{show.tour?.name}</div>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|