mirror of
https://github.com/documenso/documenso.git
synced 2025-11-23 13:11:32 +10:00
feat: initiated public profile
Signed-off-by: Adithya Krishna <aadithya794@gmail.com>
This commit is contained in:
@ -5,9 +5,10 @@ import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||
export type UpdatePublicProfileOptions = {
|
||||
userId: number;
|
||||
url: string;
|
||||
bio?: string;
|
||||
};
|
||||
|
||||
export const updatePublicProfile = async ({ userId, url }: UpdatePublicProfileOptions) => {
|
||||
export const updatePublicProfile = async ({ userId, url, bio }: UpdatePublicProfileOptions) => {
|
||||
const isUrlTaken = await prisma.user.findFirst({
|
||||
select: {
|
||||
id: true,
|
||||
@ -37,10 +38,10 @@ export const updatePublicProfile = async ({ userId, url }: UpdatePublicProfileOp
|
||||
userProfile: {
|
||||
upsert: {
|
||||
create: {
|
||||
bio: '',
|
||||
bio: bio,
|
||||
},
|
||||
update: {
|
||||
bio: '',
|
||||
bio: bio,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -88,7 +88,7 @@ export const profileRouter = router({
|
||||
.input(ZUpdatePublicProfileMutationSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const { url } = input;
|
||||
const { url, bio } = input;
|
||||
|
||||
if (IS_BILLING_ENABLED() && url.length <= 6) {
|
||||
const subscriptions = await getSubscriptionsByUserId({
|
||||
@ -108,6 +108,7 @@ export const profileRouter = router({
|
||||
const user = await updatePublicProfile({
|
||||
userId: ctx.user.id,
|
||||
url,
|
||||
bio,
|
||||
});
|
||||
|
||||
return { success: true, url: user.url };
|
||||
|
||||
@ -25,6 +25,13 @@ export const ZUpdatePublicProfileMutationSchema = z.object({
|
||||
.regex(/^[a-z0-9-]+$/, {
|
||||
message: 'Username can only container alphanumeric characters and dashes.',
|
||||
}),
|
||||
bio: z
|
||||
.string()
|
||||
.trim()
|
||||
.max(256, {
|
||||
message: 'Bio cannot be longer than 256 characters.',
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const ZUpdatePasswordMutationSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user