Archived
Initial commit
Next.js + Express event management app for Hope Family Church.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { apiFetch } from "@/lib/api";
|
||||
|
||||
export const revalidate = 60;
|
||||
|
||||
export default async function EventRedirectPage({ params }: { params: Promise<{ redirectUrl: string }> }) {
|
||||
const { redirectUrl } = await params;
|
||||
|
||||
let event: any = null;
|
||||
|
||||
try {
|
||||
event = await apiFetch<any>(`/api/events/by-alias/${redirectUrl}`);
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch event:", error);
|
||||
}
|
||||
|
||||
if (!event || event.message?.toLowerCase().includes("not found")) {
|
||||
return (
|
||||
<main className="flex flex-col items-center justify-center min-h-screen text-center px-4">
|
||||
<p className="text-6xl font-bold text-gray-200 mb-2">404</p>
|
||||
<h1 className="text-2xl font-bold mb-2">Page Not Found</h1>
|
||||
<p className="text-gray-500 mb-6">
|
||||
The page you're looking for doesn't exist.
|
||||
</p>
|
||||
<a href="/" className="text-blue-600 hover:underline transition-all duration-200">
|
||||
Back to Home →
|
||||
</a>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
if (event.isLive || event.isActive) {
|
||||
redirect(`/events/${event.id}`);
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="flex flex-col items-center justify-center min-h-screen text-center">
|
||||
<h1 className="text-3xl font-bold mb-2">This event has ended</h1>
|
||||
<p className="text-gray-600">Thanks for joining us! Stay tuned for the next one.</p>
|
||||
<a href="/" className="mt-4 text-blue-600 hover:underline">
|
||||
Back to Home →
|
||||
</a>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user