Files
documenso/packages/lib/server-only/user/update-public-profile.ts
Adithya Krishna 767679cdc6 feat: update signin signup ui
Signed-off-by: Adithya Krishna <adithya@documenso.com>
2024-02-22 01:57:46 +05:30

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,
},
});
});
};