general destination and verify
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
interface UpsertProfileInput {
|
||||
bio?: string;
|
||||
city?: string;
|
||||
instagram?: string;
|
||||
interests: string[];
|
||||
}
|
||||
|
||||
export const profileRepo = {
|
||||
async findByUserId(userId: string) {
|
||||
return prisma.userProfile.findUnique({ where: { userId } });
|
||||
},
|
||||
|
||||
async upsertByUserId(userId: string, data: UpsertProfileInput) {
|
||||
return prisma.userProfile.upsert({
|
||||
where: { userId },
|
||||
create: {
|
||||
userId,
|
||||
bio: data.bio,
|
||||
city: data.city,
|
||||
instagram: data.instagram,
|
||||
interests: data.interests,
|
||||
},
|
||||
update: {
|
||||
bio: data.bio,
|
||||
city: data.city,
|
||||
instagram: data.instagram,
|
||||
interests: data.interests,
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -24,6 +24,31 @@ export const userRepo = {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Profil sosial publik untuk halaman /u/[id]. JANGAN sertakan field sensitif
|
||||
* (email, password, KYC). Hanya yang user pilih untuk dibagikan.
|
||||
*/
|
||||
async findSocialProfileById(id: string) {
|
||||
return prisma.user.findUnique({
|
||||
where: { id },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
image: true,
|
||||
createdAt: true,
|
||||
profile: {
|
||||
select: {
|
||||
bio: true,
|
||||
city: true,
|
||||
interests: true,
|
||||
instagram: true,
|
||||
},
|
||||
},
|
||||
organizerVerification: { select: { status: true } },
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
async create(data: Prisma.UserCreateInput) {
|
||||
return prisma.user.create({ data });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user