Feat: create user page, add user bio and avatar

This commit is contained in:
Aaron William Po
2023-11-05 21:54:09 -05:00
parent fcc43c305c
commit 7f9ddb40a1
26 changed files with 324 additions and 79 deletions

View File

@@ -27,7 +27,7 @@ const createNewBeerComment = async ({
id: true,
content: true,
rating: true,
postedBy: { select: { id: true, username: true } },
postedBy: { select: { id: true, username: true, userAvatar: true } },
createdAt: true,
updatedAt: true,
},

View File

@@ -22,7 +22,9 @@ const editBeerCommentById = async ({
rating: true,
createdAt: true,
updatedAt: true,
postedBy: { select: { id: true, username: true, createdAt: true } },
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
});
};

View File

@@ -17,7 +17,9 @@ const findBeerCommentById = async ({
rating: true,
createdAt: true,
updatedAt: true,
postedBy: { select: { id: true, username: true, createdAt: true } },
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
});
};

View File

@@ -24,7 +24,9 @@ const getAllBeerComments = async ({
rating: true,
createdAt: true,
updatedAt: true,
postedBy: { select: { id: true, username: true, createdAt: true } },
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
});
};

View File

@@ -27,9 +27,11 @@ const createNewBeerStyleComment = async ({
id: true,
content: true,
rating: true,
postedBy: { select: { id: true, username: true } },
createdAt: true,
updatedAt: true,
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
});
};

View File

@@ -24,7 +24,9 @@ const getAllBeerStyleComments = async ({
rating: true,
createdAt: true,
updatedAt: true,
postedBy: { select: { id: true, username: true, createdAt: true } },
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
});
};

View File

@@ -27,9 +27,11 @@ const createNewBreweryComment = async ({
id: true,
content: true,
rating: true,
postedBy: { select: { id: true, username: true } },
createdAt: true,
updatedAt: true,
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
});
};

View File

@@ -23,7 +23,9 @@ const getAllBreweryComments = async ({
rating: true,
createdAt: true,
updatedAt: true,
postedBy: { select: { id: true, username: true, createdAt: true } },
postedBy: {
select: { id: true, username: true, createdAt: true, userAvatar: true },
},
},
orderBy: { createdAt: 'desc' },
});

View File

@@ -33,6 +33,8 @@ const createNewUser = async ({
accountIsVerified: true,
updatedAt: true,
role: true,
userAvatar: true,
bio: true,
},
});

View File

@@ -17,6 +17,8 @@ const deleteUserById = async (id: string) => {
accountIsVerified: true,
updatedAt: true,
role: true,
userAvatar: true,
bio: true,
},
});

View File

@@ -17,6 +17,17 @@ const findUserById = async (id: string) => {
accountIsVerified: true,
updatedAt: true,
role: true,
userAvatar: {
select: {
path: true,
alt: true,
caption: true,
createdAt: true,
id: true,
updatedAt: true,
},
},
bio: true,
},
});

View File

@@ -11,6 +11,17 @@ const GetUserSchema = z.object({
dateOfBirth: z.coerce.date(),
accountIsVerified: z.boolean(),
role: z.enum(['USER', 'ADMIN']),
bio: z.string().nullable(),
userAvatar: z
.object({
id: z.string().cuid(),
path: z.string().url(),
alt: z.string(),
caption: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date().nullable(),
})
.nullable(),
});
export default GetUserSchema;

View File

@@ -17,6 +17,17 @@ const updateUserToBeConfirmedById = async (id: string) => {
updatedAt: true,
dateOfBirth: true,
role: true,
bio: true,
userAvatar: {
select: {
id: true,
path: true,
alt: true,
caption: true,
createdAt: true,
updatedAt: true,
},
},
},
});

View File

@@ -8,6 +8,14 @@ const CommentQueryResult = z.object({
postedBy: z.object({
id: z.string().cuid(),
username: z.string().min(1).max(50),
userAvatar: z
.object({
id: z.string().cuid(),
path: z.string().url(),
alt: z.string().min(1).max(50),
caption: z.string().min(1).max(50),
})
.nullable(),
}),
updatedAt: z.coerce.date().nullable(),
});