|
|
@ -14,6 +14,8 @@ export const resumeCommentsRouter = createRouter().query('list', {
|
|
|
|
// For this resume, we retrieve every comment's information, along with:
|
|
|
|
// For this resume, we retrieve every comment's information, along with:
|
|
|
|
// The user's name and image to render
|
|
|
|
// The user's name and image to render
|
|
|
|
const comments = await ctx.prisma.resumesComment.findMany({
|
|
|
|
const comments = await ctx.prisma.resumesComment.findMany({
|
|
|
|
|
|
|
|
include: {
|
|
|
|
|
|
|
|
children: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
user: {
|
|
|
|
user: {
|
|
|
|
select: {
|
|
|
|
select: {
|
|
|
@ -25,13 +27,42 @@ export const resumeCommentsRouter = createRouter().query('list', {
|
|
|
|
orderBy: {
|
|
|
|
orderBy: {
|
|
|
|
createdAt: 'desc',
|
|
|
|
createdAt: 'desc',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
user: {
|
|
|
|
|
|
|
|
select: {
|
|
|
|
|
|
|
|
image: true,
|
|
|
|
|
|
|
|
name: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
orderBy: {
|
|
|
|
|
|
|
|
createdAt: 'desc',
|
|
|
|
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
resumeId,
|
|
|
|
AND: [{ resumeId }, { parentId: null }],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return comments.map((data) => {
|
|
|
|
return comments.map((data) => {
|
|
|
|
|
|
|
|
const children: Array<ResumeComment> = data.children.map((child) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
|
|
createdAt: child.createdAt,
|
|
|
|
|
|
|
|
description: child.description,
|
|
|
|
|
|
|
|
id: child.id,
|
|
|
|
|
|
|
|
resumeId: child.resumeId,
|
|
|
|
|
|
|
|
section: child.section,
|
|
|
|
|
|
|
|
updatedAt: child.updatedAt,
|
|
|
|
|
|
|
|
user: {
|
|
|
|
|
|
|
|
image: child.user.image,
|
|
|
|
|
|
|
|
name: child.user.name,
|
|
|
|
|
|
|
|
userId: child.userId,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const comment: ResumeComment = {
|
|
|
|
const comment: ResumeComment = {
|
|
|
|
|
|
|
|
children,
|
|
|
|
createdAt: data.createdAt,
|
|
|
|
createdAt: data.createdAt,
|
|
|
|
description: data.description,
|
|
|
|
description: data.description,
|
|
|
|
id: data.id,
|
|
|
|
id: data.id,
|
|
|
|