candidate data
This commit is contained in:
36
src/app/api/reports/route.ts
Normal file
36
src/app/api/reports/route.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { connectToDatabase } from '@/lib/db';
|
||||
import { Candidate } from '@/models/Candidate';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
await connectToDatabase();
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const reportType = searchParams.get('type') || 'interviews';
|
||||
const limit = Number(searchParams.get('limit') || '50');
|
||||
const page = Number(searchParams.get('page') || '1');
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
// Simplified response for the demo version
|
||||
// In a real application, we would implement the MongoDB aggregation pipeline
|
||||
const results: any[] = [];
|
||||
const total = 0;
|
||||
|
||||
return NextResponse.json({
|
||||
results,
|
||||
pagination: {
|
||||
total,
|
||||
page,
|
||||
limit,
|
||||
totalPages: Math.ceil(total / limit)
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error fetching reports:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch reports' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user