admin roadmap trips ops and payment ops
This commit is contained in:
@@ -191,6 +191,45 @@ export const tripRepo = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Admin search lintas trip. Tidak filter berdasarkan status departure (admin
|
||||
* boleh lihat semua: OPEN/FULL/CLOSED/COMPLETED). Include _count peserta
|
||||
* aktif untuk indikator cepat.
|
||||
*/
|
||||
async searchForAdmin(filters: {
|
||||
q?: string;
|
||||
status?: "OPEN" | "FULL" | "CLOSED" | "COMPLETED";
|
||||
}) {
|
||||
const where: Prisma.TripWhereInput = {};
|
||||
if (filters.status) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
if (filters.q) {
|
||||
where.OR = [
|
||||
{ title: { contains: filters.q, mode: "insensitive" } },
|
||||
{ destination: { contains: filters.q, mode: "insensitive" } },
|
||||
{ location: { contains: filters.q, mode: "insensitive" } },
|
||||
{ organizer: { name: { contains: filters.q, mode: "insensitive" } } },
|
||||
{ organizer: { email: { contains: filters.q, mode: "insensitive" } } },
|
||||
];
|
||||
}
|
||||
return prisma.trip.findMany({
|
||||
where,
|
||||
include: {
|
||||
organizer: { select: { id: true, name: true, email: true } },
|
||||
images: { orderBy: { order: "asc" }, take: 1 },
|
||||
_count: {
|
||||
select: {
|
||||
participants: { where: { status: { not: "CANCELLED" } } },
|
||||
bookings: { where: { status: "PAID" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: { date: "desc" },
|
||||
take: 100,
|
||||
});
|
||||
},
|
||||
|
||||
/** Semua trip yang dibuat user (semua status), terbaru dulu — untuk profil. */
|
||||
async findByOrganizerId(organizerId: string) {
|
||||
return prisma.trip.findMany({
|
||||
|
||||
Reference in New Issue
Block a user