
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function main() {
  const logs = await prisma.whatsappLog.findMany({
    orderBy: { createdAt: 'desc' },
    take: 3,
    select: { templateName: true, payload: true, response: true, status: true, createdAt: true }
  });
  logs.forEach((l, i) => {
    console.log(`\n=== LOG #${i+1} [${l.status}] at ${l.createdAt} ===`);
    console.log('Template:', l.templateName);
    const payload = JSON.parse(l.payload || '{}');
    console.log('Fields:', payload.fields);
    console.log('Cat:', payload.cat);
    console.log('Headimg:', payload.headimg);
    console.log('Response:', l.response);
  });
}

main().catch(console.error).finally(() => prisma.$disconnect());
