feat: update ui

Signed-off-by: Adithya Krishna <adithya@documenso.com>
This commit is contained in:
Adithya Krishna
2024-02-24 22:38:53 +05:30
committed by Mythie
parent b1261510d2
commit b498f8edb7
22 changed files with 442 additions and 237 deletions

View File

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

View File

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