Repository navigation
Expand file tree
/
Copy pathtest-partner-api.js
More file actions
64 lines (56 loc) · 1.63 KB
/
Copy pathtest-partner-api.js
File metadata and controls
64 lines (56 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function testPartnerAPI() {
console.log('🧪 Testing Partner API Logic...\n');
const partner = await prisma.user.findUnique({
where: { email: 'partner@jejakin.com' },
});
console.log('Partner ID:', partner.id);
console.log('');
// Simulate API GET /api/bookings for partner
const where = {
destination: {
userId: partner.id,
},
};
const bookings = await prisma.booking.findMany({
where,
orderBy: {
createdAt: 'desc',
},
include: {
destination: {
select: {
id: true,
name: true,
location: true,
images: true,
category: true,
},
},
user: {
select: {
id: true,
name: true,
email: true,
phone: true,
},
},
},
});
console.log('✅ Bookings found for partner:', bookings.length);
console.log('');
console.log('Booking Details:');
bookings.forEach((booking, index) => {
console.log(`\n${index + 1}. Booking Code: ${booking.bookingCode}`);
console.log(` Customer: ${booking.user.name} (${booking.user.email})`);
console.log(` Destination: ${booking.destination.name}`);
console.log(` Visit Date: ${booking.visitDate}`);
console.log(` People: ${booking.numberOfPeople}`);
console.log(` Total: Rp ${booking.totalPrice.toLocaleString('id-ID')}`);
console.log(` Status: ${booking.status}`);
console.log(` Payment: ${booking.paymentStatus}`);
});
await prisma.$disconnect();
}
testPartnerAPI().catch(console.error);