diff --git a/apps/admin/app/(main)/jobs/[jobId]/StatusSelect.tsx b/apps/admin/app/(main)/jobs/[jobId]/StatusSelect.tsx new file mode 100644 index 0000000..d4b91a4 --- /dev/null +++ b/apps/admin/app/(main)/jobs/[jobId]/StatusSelect.tsx @@ -0,0 +1,58 @@ +'use client'; + +import { useState, useTransition } from 'react'; +import { + Select, + SelectTrigger, + SelectContent, + SelectItem, + SelectValue, +} from '@workspace/ui/components/select'; + +const STATUS_OPTIONS = [ + 'in review', + 'Online Assessment', + 'Interview round', + 'offer given', + 'accepted', + 'rejected', +]; + +interface StatusSelectProps { + applicationId: number; + initialStatus: string; + studentId: number; +} + +export default function StatusSelect({ + applicationId, + initialStatus, + studentId, +}: StatusSelectProps) { + const [status, setStatus] = useState(initialStatus); + const [isPending, startTransition] = useTransition(); + + const handleChange = (value: string) => { + setStatus(value); // Optimistic update + startTransition(async () => { + await fetch(`/api/applications/${applicationId}/status`, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ status: value, studentId }), + }); + }); + }; + + return ( + + ); +} diff --git a/apps/admin/app/(main)/jobs/[jobId]/page.tsx b/apps/admin/app/(main)/jobs/[jobId]/page.tsx index efd02cc..577fd08 100644 --- a/apps/admin/app/(main)/jobs/[jobId]/page.tsx +++ b/apps/admin/app/(main)/jobs/[jobId]/page.tsx @@ -18,6 +18,7 @@ import { Clock } from 'lucide-react'; import Link from 'next/link'; +import StatusSelect from './StatusSelect'; interface JobPageProps { params: { jobId: string }; @@ -33,7 +34,11 @@ export default async function JobDetailPage({ params }: JobPageProps) { 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 companyRes = await db + .select() + .from(companies) + .where(eq(companies.id, job.companyId)) + .limit(1); const company = companyRes[0]; const applicants = await db @@ -43,6 +48,7 @@ export default async function JobDetailPage({ params }: JobPageProps) { firstName: students.firstName, lastName: students.lastName, email: students.email, + studentId: students.id, }) .from(applications) .leftJoin(students, eq(applications.studentId, students.id)) @@ -80,9 +86,9 @@ export default async function JobDetailPage({ params }: JobPageProps) {
Application Deadline
-{job.applicationDeadline.toLocaleDateString()}
++ {job.applicationDeadline.toLocaleDateString()} +
Students will appear here once they apply for this job.
++ Students will appear here once they apply for this job. +