mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Applications need a Server
This commit is contained in:
@@ -19,11 +19,29 @@ export async function POST(request: NextRequest) {
|
||||
orderBy: { name: 'asc' }
|
||||
});
|
||||
|
||||
const serverIds = applications
|
||||
.map(app => app.serverId)
|
||||
.filter((id): id is number => id !== null);
|
||||
|
||||
const servers = await prisma.server.findMany({
|
||||
where: {
|
||||
id: {
|
||||
in: serverIds
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const applicationsWithServers = applications.map(app => ({
|
||||
...app,
|
||||
server: servers.find(s => s.id === app.serverId)?.name || 'No server'
|
||||
}));
|
||||
|
||||
const totalCount = await prisma.application.count();
|
||||
const maxPage = Math.ceil(totalCount / ITEMS_PER_PAGE);
|
||||
|
||||
return NextResponse.json({
|
||||
applications,
|
||||
applications: applicationsWithServers,
|
||||
servers,
|
||||
maxPage
|
||||
});
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user