import { Card, CardContent, CardHeader, CardTitle } from "@workspace/ui/components/card" import { Button } from "@workspace/ui/components/button" import { Badge } from "@workspace/ui/components/badge" import { Separator } from "@workspace/ui/components/separator" import Link from "next/link" import { db, companies, jobs, students } from "@workspace/db" import { Building2, Briefcase, MapPin, DollarSign, Calendar, ExternalLink, TrendingUp, Users, Star, Clock, CheckCircle, ArrowRight, Search, Filter, Bookmark, Share2, Eye } from "lucide-react" async function getDashboardData() { try { // Get companies with their active jobs const result = await db.query.companies.findMany({ with: { jobs: { where: (job, {eq}) => eq(job.active, true), } } }) // Filter to only include companies that have active jobs const companiesWithActiveJobs = result.filter((company) => company.jobs.length > 0) // Get total student count for stats const studentCount = await db.select().from(students) return { companies: companiesWithActiveJobs, totalStudents: studentCount.length } } catch (error) { console.error("Database query error:", error) return { companies: [], totalStudents: 0 } } } export default async function DashboardPage() { const { companies: data, totalStudents } = await getDashboardData() // Calculate stats const totalActiveJobs = data.reduce((acc, company) => acc + company.jobs.filter((job) => job.active).length, 0) const featuredCompanies = data.slice(0, 3) // Top 3 companies for featured section const recentJobs = data.flatMap(company => company.jobs.slice(0, 2).map(job => ({ ...job, company })) ).slice(0, 6) return (
{/* Hero Section */}

Discover Your Dream Career

Explore opportunities from top companies and find the perfect role that matches your skills and aspirations

{/* Stats Section */}

{data.length}

Active Companies

{totalActiveJobs}

Open Positions

{totalStudents}

Students

95%

Success Rate

{/* Featured Companies Section */}

Featured Companies

Top companies actively hiring talented students like you

{featuredCompanies.map((company) => (
Featured

{company.name}

{company.email}

{company.jobs.length} jobs
{company.description && company.description !== "N/A" && (

{company.description}

)}
{company.jobs.slice(0, 2).map((job) => (

{job.title}

{job.location && job.location !== "N/A" && ( {job.location} )} {job.salary && job.salary !== "N/A" && ( {job.salary} )}
))}
))}
{/* Recent Job Opportunities */}

Recent Opportunities

Latest job postings from top companies

{recentJobs.map((job) => (

{job.title}

{job.company.name}

Active
{job.location && job.location !== "N/A" && (
{job.location}
)} {job.salary && job.salary !== "N/A" && (
{job.salary}
)}
Deadline: {job.applicationDeadline.toLocaleDateString()}
Min CGPA: {job.minCGPA}
{job.description && job.description !== "N/A" && (

{job.description}

)}
{job.link && ( )}
))}
{/* Call to Action */}

Ready to Start Your Career Journey?

Join thousands of students who have found their dream jobs through NextPlacement

) } export const dynamic = "force-dynamic"