mirror of
https://github.com/documenso/documenso.git
synced 2025-11-18 18:51:37 +10:00
33 lines
830 B
TypeScript
33 lines
830 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
import type { User, UserProfile } from '@documenso/prisma/client';
|
|
|
|
import { getUserById } from './get-user-by-id';
|
|
|
|
export type UpdatePublicProfileOptions = {
|
|
id: User['id'];
|
|
userProfile: UserProfile;
|
|
};
|
|
|
|
export const updatePublicProfile = async ({ id, userProfile }: UpdatePublicProfileOptions) => {
|
|
const user = await getUserById({ id });
|
|
console.log('Adi', user);
|
|
// Existence check
|
|
await prisma.userProfile.findFirstOrThrow({
|
|
where: {
|
|
profileURL: user.profileURL ?? '',
|
|
},
|
|
});
|
|
|
|
return await prisma.$transaction(async (tx) => {
|
|
await tx.userProfile.update({
|
|
where: {
|
|
profileURL: user.profileURL!,
|
|
},
|
|
data: {
|
|
profileURL: userProfile.profileURL,
|
|
profileBio: userProfile.profileBio,
|
|
},
|
|
});
|
|
});
|
|
};
|