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, AlertCircle } 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, success: true } } catch (error) { console.error("Database query error:", error) return { companies: [], totalStudents: 0, success: false, error: "Failed to load dashboard data" } } } export default async function DashboardPage() { const { companies: data, totalStudents, success, error } = 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 (
Explore opportunities from top companies and find the perfect role that matches your skills and aspirations
Active Companies
Open Positions
Students
Success Rate
Top companies actively hiring talented students like you
{company.email}
{company.description}
)}Check back later for exciting opportunities
Latest job postings from top companies
{job.company.name}
{job.description}
)}Check back later for new job postings
Join thousands of students who have found their dream jobs through Placement Portal