import { redirect } from 'next/navigation' import Link from 'next/link' import type { Route } from 'next' import { prisma } from '@/lib/prisma' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Logo } from '@/components/shared/logo' import { FileText, Calendar, ArrowRight, ExternalLink } from 'lucide-react' export const dynamic = 'force-dynamic' export default async function ApplyLandingPage() { // Get all published, public application forms const forms = await prisma.applicationForm.findMany({ where: { status: 'PUBLISHED', isPublic: true, OR: [ { opensAt: null }, { opensAt: { lte: new Date() } }, ], AND: [ { OR: [ { closesAt: null }, { closesAt: { gte: new Date() } }, ], }, ], }, orderBy: { createdAt: 'desc' }, select: { id: true, name: true, description: true, publicSlug: true, opensAt: true, closesAt: true, steps: { select: { id: true }, }, }, }) // If exactly one form is available, redirect to it if (forms.length === 1 && forms[0].publicSlug) { const form = forms[0] const hasSteps = form.steps && form.steps.length > 0 const url = hasSteps ? `/apply/${form.publicSlug}/wizard` : `/apply/${form.publicSlug}` redirect(url as Route) } // If no forms are available, show a message if (forms.length === 0) { return (

Applications Not Open

There are currently no open applications. Please check back later or visit our website for more information.

) } // Multiple forms available - show selection return (

Apply Now

Select an application form below to get started.

{forms.map((form) => { const hasSteps = form.steps && form.steps.length > 0 const url = hasSteps ? `/apply/${form.publicSlug}/wizard` : `/apply/${form.publicSlug}` return (
{form.name} {form.description && ( {form.description} )} {(form.opensAt || form.closesAt) && (
{form.closesAt && ( Closes: {new Date(form.closesAt).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric', })} )}
)}
) })}

Having trouble? Contact us at{' '} support@monaco-opc.com

) }