mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
@ -1,14 +0,0 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import type { UserProfile } from '@documenso/prisma/client';
|
||||
|
||||
export interface GetPublicProfileByURLOptions {
|
||||
profileURL: UserProfile['profileURL'];
|
||||
}
|
||||
|
||||
export const getPublicProfileByURL = async ({ profileURL }: GetPublicProfileByURLOptions) => {
|
||||
return await prisma.userProfile.findFirstOrThrow({
|
||||
where: {
|
||||
profileURL: profileURL,
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -5,27 +5,30 @@ import { getUserById } from './get-user-by-id';
|
||||
|
||||
export type UpdatePublicProfileOptions = {
|
||||
id: User['id'];
|
||||
userProfile: UserProfile;
|
||||
profileURL: UserProfile['profileURL'];
|
||||
};
|
||||
|
||||
export const updatePublicProfile = async ({ id, userProfile }: UpdatePublicProfileOptions) => {
|
||||
export const updatePublicProfile = async ({ id, profileURL }: UpdatePublicProfileOptions) => {
|
||||
const user = await getUserById({ id });
|
||||
console.log('Adi', user);
|
||||
// Existence check
|
||||
await prisma.userProfile.findFirstOrThrow({
|
||||
where: {
|
||||
profileURL: user.profileURL ?? '',
|
||||
profileURL: user.profileURL ?? undefined,
|
||||
},
|
||||
});
|
||||
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
await tx.userProfile.create({
|
||||
data: {
|
||||
profileURL,
|
||||
},
|
||||
});
|
||||
await tx.userProfile.update({
|
||||
where: {
|
||||
profileURL: user.profileURL!,
|
||||
profileURL: user.profileURL ?? undefined,
|
||||
},
|
||||
data: {
|
||||
profileURL: userProfile.profileURL,
|
||||
profileBio: userProfile.profileBio,
|
||||
profileURL: profileURL,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user