auth, trips and join trips

This commit is contained in:
2026-04-16 14:51:54 +07:00
parent de0d1c5413
commit 237caad488
49 changed files with 11343 additions and 334 deletions
+45
View File
@@ -0,0 +1,45 @@
import { prisma } from "@/lib/prisma";
import { Prisma } from "@/app/generated/prisma/client";
export const tripRepo = {
async findAll() {
return prisma.trip.findMany({
include: {
organizer: { select: { id: true, name: true, image: true } },
_count: { select: { participants: true } },
},
orderBy: { date: "asc" },
});
},
async findOpen() {
return prisma.trip.findMany({
where: { status: "OPEN", date: { gte: new Date() } },
include: {
organizer: { select: { id: true, name: true, image: true } },
_count: { select: { participants: true } },
},
orderBy: { date: "asc" },
});
},
async findById(id: string) {
return prisma.trip.findUnique({
where: { id },
include: {
organizer: { select: { id: true, name: true, email: true, image: true } },
participants: {
include: { user: { select: { id: true, name: true, image: true } } },
},
},
});
},
async create(data: Prisma.TripCreateInput) {
return prisma.trip.create({ data });
},
async updateStatus(id: string, status: "OPEN" | "FULL" | "CLOSED" | "COMPLETED") {
return prisma.trip.update({ where: { id }, data: { status } });
},
};