added infinite scrolling to frontend and displaying vote information
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { searchMapNames } from '@/lib/queries';
|
||||
|
||||
const PAGE_SIZE = 100;
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const q = req.nextUrl.searchParams.get('q')?.trim() ?? '';
|
||||
const maps = await searchMapNames(q);
|
||||
return NextResponse.json({ maps });
|
||||
const offset = Math.max(0, Number(req.nextUrl.searchParams.get('offset')) || 0);
|
||||
|
||||
const maps = await searchMapNames(q, PAGE_SIZE, offset);
|
||||
const hasMore = maps.length === PAGE_SIZE;
|
||||
|
||||
return NextResponse.json({ maps, hasMore });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user