'use client'; import { useState, useEffect } from 'react'; 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 { Input } from '@workspace/ui/components/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@workspace/ui/components/select'; import { Building2, MapPin, DollarSign, Calendar, Clock, Search, Filter, Bookmark, Share2, Eye, ArrowRight, Briefcase, Users, Star, CheckCircle, ExternalLink, Loader2, AlertCircle, FileText, Download, } from 'lucide-react'; import JobApplicationModal from '@/components/job-application-modal'; import { type InferSelectModel } from '@workspace/db/drizzle'; import { jobs, companies, resumes } from '@workspace/db/schema'; export type Job = InferSelectModel & { company: typeof companies.$inferSelect; }; export type Resume = typeof resumes.$inferSelect; const JobDescription = ({ job }: { job: Job }) => { if (job.fileUrl && job.fileName) { const apiFileUrl = `/api/files/job-descriptions/${job.fileName}`; // Display file information return (

Job Description File

{job.fileName}

{job.fileType === 'pdf' ? ( ) : ( )}
); } // Display text description if (job.description) { return

{job.description}

; } // Fallback return

No description available

; }; export default function JobsPage({ eligibleJobs, ineligibleJobs, resumes, studentId, appliedJobIds = [], }: { eligibleJobs: Job[]; ineligibleJobs: Job[]; resumes: Resume[]; studentId: number; appliedJobIds?: number[]; }) { const [filteredJobs, setFilteredJobs] = useState([]); const [activeTab, setActiveTab] = useState<'eligible' | 'ineligible'>('eligible'); const [searchTerm, setSearchTerm] = useState(''); const [locationFilter, setLocationFilter] = useState('all'); const [jobTypeFilter, setJobTypeFilter] = useState('all'); const [showLoadMore, setShowLoadMore] = useState(false); const allJobs = [...eligibleJobs, ...ineligibleJobs]; useEffect(() => { filterJobs(); }, [eligibleJobs, ineligibleJobs, activeTab, searchTerm, locationFilter, jobTypeFilter]); const filterJobs = () => { let base = activeTab === 'eligible' ? eligibleJobs : ineligibleJobs; let filtered = [...base]; // Search filter if (searchTerm) { filtered = filtered.filter( (job) => job.title.toLowerCase().includes(searchTerm.toLowerCase()) || job.company.name.toLowerCase().includes(searchTerm.toLowerCase()) || (job.description && job.description.toLowerCase().includes(searchTerm.toLowerCase())) || (job.fileName && job.fileName.toLowerCase().includes(searchTerm.toLowerCase())), ); } // Location filter if (locationFilter && locationFilter !== 'all') { filtered = filtered.filter((job) => job.location.toLowerCase().includes(locationFilter.toLowerCase()), ); } // Job type filter (simplified - could be enhanced with job type field) if (jobTypeFilter && jobTypeFilter !== 'all') { filtered = filtered.filter((job) => job.title.toLowerCase().includes(jobTypeFilter.toLowerCase()), ); } setFilteredJobs(filtered); setShowLoadMore(filtered.length > 6); }; const handleSearch = (value: string) => { setSearchTerm(value); }; const handleLocationFilter = (value: string) => { setLocationFilter(value); }; const handleJobTypeFilter = (value: string) => { setJobTypeFilter(value); }; const clearFilters = () => { setSearchTerm(''); setLocationFilter('all'); setJobTypeFilter('all'); }; const displayedJobs = filteredJobs.slice(0, showLoadMore ? 6 : filteredJobs.length); return (
{/* Header */}

Browse Jobs

Find the perfect opportunity that matches your skills and aspirations

{/* Search and Filter Section */}
handleSearch(e.target.value)} />
{(searchTerm || (locationFilter && locationFilter !== 'all') || (jobTypeFilter && jobTypeFilter !== 'all')) && (
{filteredJobs.length} of {allJobs.length} jobs
)}
{/* Stats */}

Total Jobs

{allJobs.length}

Active Companies

{new Set(allJobs.map((job) => job.company.name)).size}

Remote Jobs

{allJobs.filter((job) => job.location.toLowerCase().includes('remote')).length}

Avg Salary

$28/hr

{/* Tabs */}

Select a category to view jobs

Switch between eligible and not eligible jobs based on your profile

{/* Jobs Grid */}
{displayedJobs.map((job) => (

{job.title}

{job.company.name}

{job.location} {job.salary}
Active
Deadline: {job.applicationDeadline.toLocaleDateString()}
Min CGPA: {job.minCGPA}
{activeTab === 'eligible' ? ( ) : ( )} {job.link && ( )}
))}
{/* Load More */} {showLoadMore && (
)} {/* Empty State */} {filteredJobs.length === 0 && (

No jobs found

Try adjusting your search criteria or check back later for new opportunities

)}
); }