- wrap root layout with QueryProvider for React Query - replace market UnderConstruction placeholder with MarketClient and real data fetching - implement search, pagination, and sort via search params using getActiveListings - add necessary client components and queries - update dependencies (e.g., prisma, pkg-types)
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { secureLogger } from "@/lib/secure-logger";
|
|
import { getListingById } from "@/lib/prisma/queries/listings";
|
|
import { getMainCharacterByUserId } from "@/lib/prisma/queries/characters";
|
|
|
|
/**
|
|
* GET /api/listings/[id]/seller
|
|
* Retorna informações do vendedor (nome do personagem)
|
|
*/
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: { id: string } }
|
|
) {
|
|
try {
|
|
const listingId = parseInt(params.id, 10);
|
|
if (isNaN(listingId)) {
|
|
return NextResponse.json(
|
|
{ success: false, error: "ID de anúncio inválido" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const listing = await getListingById(listingId);
|
|
if (!listing) {
|
|
return NextResponse.json(
|
|
{ success: false, error: "Anúncio não encontrado" },
|
|
{ status: 404 }
|
|
);
|
|
}
|
|
|
|
// Buscar personagem principal do vendedor no servidor do listing
|
|
const character = await getMainCharacterByUserId(listing.seller_id, listing.server_name);
|
|
|
|
return NextResponse.json(
|
|
{
|
|
success: true,
|
|
seller: {
|
|
user_id: listing.seller_id,
|
|
character_name: character?.character_name || null,
|
|
server_name: listing.server_name,
|
|
},
|
|
},
|
|
{ status: 200 }
|
|
);
|
|
} catch (error) {
|
|
secureLogger.error("❌ Erro ao buscar informações do vendedor", {
|
|
error: error instanceof Error ? error.message : "Erro desconhecido",
|
|
stack: error instanceof Error ? error.stack : undefined,
|
|
});
|
|
|
|
return NextResponse.json(
|
|
{ success: false, error: "Erro ao buscar informações do vendedor" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|