feat(item-card): add 'market'/'catalog' mode prop with defensive price checks

Introduces optional `mode` prop ("market"/"catalog") to conditionally render components like rarity badges. Adds defensive checks for missing price data and priceHistory properties to prevent runtime errors. New icons `Badge` and `Boxes` imported from lucide-react.
This commit is contained in:
Evandro Fonseca Junior committed 2025-10-30 14:10:46 -03:00
1 parent 29ba5aece0
commit 44d7f8ce81
21 files changed
+1181 -714

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { NextRequest } from "next/server";
import path from "node:path";
function getDb() {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Database = require("better-sqlite3");
const dbPath = path.join(process.cwd(), "data", "tibiawiki.db");
return new Database(dbPath, { readonly: true, fileMustExist: true });
}
export async function GET(_req: NextRequest) {
try {
const db = getDb();
const tables = db
.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name <> 'sqlite_sequence' ORDER BY name")
.all() as { name: string }[];
db.close();
// Retorna nomes das tabelas (PT) para usar como categorias
return Response.json({ categories: tables.map((t) => t.name) });
} catch (e: any) {
return Response.json({ error: e?.message || "Erro" }, { status: 500 });
}
}