37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
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 }
|
|
);
|
|
}
|
|
}
|