added infinite scrolling to frontend and displaying vote information

This commit is contained in:
jenz
2026-08-25 21:34:45 +02:00
parent ab481d6d65
commit 0634fde335
7 changed files with 240 additions and 25 deletions
@@ -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 });
}