import { getSession } from '@/lib/session' import { redeemPromoCode } from '@/lib/promo' /** Canjea un código de promoción por PD/PV en la cuenta en sesión. */ export async function POST(request: Request) { const session = await getSession() if (!session.accountId || !session.username) { return Response.json({ success: false, error: 'notAuthenticated' }, { status: 401 }) } let body: Record = {} try { body = await request.json() } catch { return Response.json({ success: false, error: 'invalidRequest' }, { status: 400 }) } return Response.json(await redeemPromoCode(session.accountId, String(body.code ?? ''))) }