import { db, jobs, companies, applications, students } from '@workspace/db'; import { eq } from '@workspace/db/drizzle'; import { notFound } from 'next/navigation'; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@workspace/ui/components/card'; import { Table, TableBody, TableHead, TableHeader, TableRow, TableCell } from '@workspace/ui/components/table'; import { Badge } from '@workspace/ui/components/badge'; import { Button } from '@workspace/ui/components/button'; import { ArrowLeft, MapPin, DollarSign, Calendar, GraduationCap, Building2, ExternalLink, Users, FileText, Clock } from 'lucide-react'; import Link from 'next/link'; interface JobPageProps { params: { jobId: string }; } export const dynamic = 'force-dynamic'; export default async function JobDetailPage({ params }: JobPageProps) { const jobId = Number(params.jobId); if (isNaN(jobId)) notFound(); const jobRes = await db.select().from(jobs).where(eq(jobs.id, jobId)).limit(1); if (jobRes.length === 0 || !jobRes[0]) notFound(); const job = jobRes[0]; const companyRes = await db.select().from(companies).where(eq(companies.id, job.companyId)).limit(1); const company = companyRes[0]; const applicants = await db .select({ applicationId: applications.id, status: applications.status, firstName: students.firstName, lastName: students.lastName, email: students.email, }) .from(applications) .leftJoin(students, eq(applications.studentId, students.id)) .where(eq(applications.jobId, jobId)); return (
{/* Header */}

Job Details

View and manage job information

{/* Main Job Information */}
{/* Job Header Card */}
{company?.imageURL ? ( {company.name} ) : ( )}
{job.title} {company?.name ?? 'Unknown Company'}
{job.active ? 'Active' : 'Inactive'}
{/* Key Details Grid */}

Location

{job.location}

Salary

{job.salary}

Application Deadline

{job.applicationDeadline.toLocaleDateString()}

Applications

{applicants.length} students

{/* Job Link */}
{/* Job Description */} Job Description

{job.description}

{/* Academic Requirements */} Academic Requirements

{job.minCGPA}

Minimum CGPA

{job.minSSC}%

Minimum SSC

{job.minHSC}%

Minimum HSC

Dead KT: {job.allowDeadKT ? 'Allowed' : 'Not Allowed'}
Live KT: {job.allowLiveKT ? 'Allowed' : 'Not Allowed'}
{/* Sidebar */}
{/* Company Information */} Company Details
{company?.imageURL ? ( {company.name} ) : ( )}

{company?.name}

{company?.email}

{company?.description && (

{company.description}

)}
{/* Job Timeline */} Timeline
Created {job.createdAt.toLocaleDateString()}
Last Updated {job.updatedAt.toLocaleDateString()}
Application Deadline {job.applicationDeadline.toLocaleDateString()}
{/* Applications Section */}
Student Applications ({applicants.length}) View all students who have applied for this position {applicants.length === 0 ? (

No applications yet

Students will appear here once they apply for this job.

) : (
Name Email Status {applicants.map((applicant) => ( {`${applicant.firstName ?? ''} ${applicant.lastName ?? ''}`.trim() || 'Unknown'} {applicant.email} {applicant.status.charAt(0).toUpperCase() + applicant.status.slice(1)} ))}
)}
); }