feat: (web) add quest table component for admin quests page

- Add getAllQuests() method to quest.service.ts
- Add GET /api/quests endpoint to server.ts
- Create QuestTable component with data display, formatting, and states
- Update AdminQuests.tsx to fetch and display quests above the form
- Add onSuccess callback to QuestForm for refresh handling
This commit is contained in:
syntaxbullet
2026-01-16 15:12:41 +01:00
parent d243a11bd3
commit 3ef9773990
5 changed files with 377 additions and 2 deletions

View File

@@ -197,6 +197,31 @@ export async function createWebServer(config: WebServerConfig = {}): Promise<Web
}
}
if (url.pathname === "/api/quests" && req.method === "GET") {
try {
const { questService } = await import("@shared/modules/quest/quest.service");
const quests = await questService.getAllQuests();
return Response.json({
success: true,
data: quests.map(q => ({
id: q.id,
name: q.name,
description: q.description,
triggerEvent: q.triggerEvent,
requirements: q.requirements,
rewards: q.rewards,
})),
});
} catch (error) {
logger.error("web", "Error fetching quests", error);
return Response.json(
{ error: "Failed to fetch quests", details: error instanceof Error ? error.message : String(error) },
{ status: 500 }
);
}
}
// Settings Management
if (url.pathname === "/api/settings") {
try {