kyc user and upload partial update encrypt nik and picture

This commit is contained in:
2026-04-27 21:48:24 +07:00
parent b31fe675ae
commit a92b4a8fd9
51 changed files with 5180 additions and 452 deletions
+59
View File
@@ -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,
},
});
},
};