Files
documenso/packages/lib/server-only/team/update-team-public-profile.ts
2024-06-06 15:28:02 +10:00

39 lines
615 B
TypeScript

import { prisma } from '@documenso/prisma';
export type UpdatePublicProfileOptions = {
userId: number;
teamId: number;
data: {
bio?: string;
enabled?: boolean;
};
};
export const updateTeamPublicProfile = async ({
userId,
teamId,
data,
}: UpdatePublicProfileOptions) => {
return await prisma.team.update({
where: {
id: teamId,
members: {
some: {
userId,
},
},
},
data: {
profile: {
upsert: {
create: data,
update: data,
},
},
},
include: {
profile: true,
},
});
};