65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
export const dynamic = "force-dynamic";
|
|
|
|
import Link from "next/link";
|
|
import { notFound } from "next/navigation";
|
|
import { getLettersByLocation } from "@/lib/letters";
|
|
import { PageHeader } from "@/components/page-header";
|
|
import { Card, CardContent } from "@/components/ui/card";
|
|
|
|
export default async function LettersByLocationPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ name: string }>;
|
|
}) {
|
|
const { name: encodedName } = await params;
|
|
const name = decodeURIComponent(encodedName);
|
|
|
|
const letters = await getLettersByLocation(name);
|
|
if (letters.length === 0) notFound();
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background">
|
|
<PageHeader>
|
|
<Link
|
|
href="/letters?view=location"
|
|
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
>
|
|
← Letters by Location
|
|
</Link>
|
|
<h1 className="mt-3 text-3xl font-bold text-foreground">
|
|
Letters from {name}
|
|
</h1>
|
|
<p className="mt-1 text-muted-foreground">
|
|
{letters.length} {letters.length === 1 ? "letter" : "letters"}
|
|
</p>
|
|
</PageHeader>
|
|
|
|
<main className="max-w-3xl mx-auto px-6 py-8">
|
|
<Card className="divide-y divide-border">
|
|
<CardContent className="p-0">
|
|
<ul className="divide-y divide-border">
|
|
{letters.map((letter) => (
|
|
<li key={letter.slug}>
|
|
<Link
|
|
href={`/letters/${letter.slug}`}
|
|
className="flex flex-col sm:flex-row sm:items-center sm:justify-between px-5 py-4 gap-1 sm:gap-4 hover:bg-muted transition-colors"
|
|
>
|
|
<div className="min-w-0">
|
|
<p className="font-medium text-foreground">
|
|
To: {letter.recipientDisplay}
|
|
</p>
|
|
<p className="text-sm text-muted-foreground">
|
|
{letter.date || "Undated"}
|
|
</p>
|
|
</div>
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</CardContent>
|
|
</Card>
|
|
</main>
|
|
</div>
|
|
);
|
|
}
|