kyc user and upload partial update encrypt nik and picture
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { Prisma } from "@/app/generated/prisma/client";
|
||||
|
||||
export const organizerRepo = {
|
||||
async findByUserId(userId: string) {
|
||||
return prisma.organizerVerification.findUnique({ where: { userId } });
|
||||
},
|
||||
|
||||
async findById(id: string) {
|
||||
return prisma.organizerVerification.findUnique({ where: { id } });
|
||||
},
|
||||
|
||||
async findByNik(nik: string) {
|
||||
return prisma.organizerVerification.findUnique({ where: { nik } });
|
||||
},
|
||||
|
||||
async upsertForUser(
|
||||
userId: string,
|
||||
data: Omit<Prisma.OrganizerVerificationUncheckedCreateInput, "id" | "userId" | "createdAt" | "updatedAt">
|
||||
) {
|
||||
return prisma.organizerVerification.upsert({
|
||||
where: { userId },
|
||||
create: { userId, ...data },
|
||||
update: data,
|
||||
});
|
||||
},
|
||||
|
||||
async listByStatus(status?: "PENDING" | "APPROVED" | "REJECTED") {
|
||||
return prisma.organizerVerification.findMany({
|
||||
where: status ? { status } : undefined,
|
||||
orderBy: { createdAt: "desc" },
|
||||
include: {
|
||||
user: { select: { id: true, name: true, email: true } },
|
||||
reviewedBy: { select: { id: true, name: true, email: true } },
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async updateReview(
|
||||
id: string,
|
||||
data: {
|
||||
status: "APPROVED" | "REJECTED";
|
||||
rejectionReason?: string | null;
|
||||
reviewedById: string;
|
||||
}
|
||||
) {
|
||||
const now = new Date();
|
||||
return prisma.organizerVerification.update({
|
||||
where: { id },
|
||||
data: {
|
||||
status: data.status,
|
||||
rejectionReason: data.rejectionReason ?? null,
|
||||
reviewedById: data.reviewedById,
|
||||
reviewedAt: now,
|
||||
verifiedAt: data.status === "APPROVED" ? now : null,
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -98,7 +98,7 @@ export const tripRepo = {
|
||||
name: true,
|
||||
email: true,
|
||||
image: true,
|
||||
isVerified: true,
|
||||
organizerVerification: { select: { status: true } },
|
||||
},
|
||||
},
|
||||
images: { orderBy: { order: "asc" } },
|
||||
|
||||
Reference in New Issue
Block a user