fix: review avatar uses authorId instead of displayName, show reviews for hidden products

This commit is contained in:
Kirill
2026-05-22 19:14:22 +05:00
parent a96944328d
commit 02c7d7ba36
4 changed files with 9 additions and 5 deletions
+5 -3
View File
@@ -38,9 +38,9 @@ export async function registerPublicReviewRoutes(fastify) {
const take = Math.min(parsed, 5)
const rows = await prisma.review.findMany({
where: { status: 'approved', product: { published: true } },
where: { status: 'approved' },
include: {
user: { select: { email: true, displayName: true, avatar: true, avatarStyle: true } },
user: { select: { id: true, email: true, displayName: true, avatar: true, avatarStyle: true } },
product: { select: { id: true, title: true, published: true, slug: true } },
},
orderBy: { createdAt: 'desc' },
@@ -53,6 +53,7 @@ export async function registerPublicReviewRoutes(fastify) {
text: r.text,
imageUrl: r.imageUrl,
createdAt: r.createdAt,
authorId: r.user?.id ?? r.userId,
authorDisplay: publicReviewAuthorDisplay(r.user),
authorAvatar: r.user?.avatar ?? null,
authorAvatarStyle: r.user?.avatarStyle ?? null,
@@ -87,7 +88,7 @@ export async function registerPublicReviewRoutes(fastify) {
const rawItems = await prisma.review.findMany({
where,
include: {
user: { select: { email: true, displayName: true, avatar: true, avatarStyle: true } },
user: { select: { id: true, email: true, displayName: true, avatar: true, avatarStyle: true } },
},
orderBy: { createdAt: 'desc' },
skip: (page - 1) * pageSize,
@@ -100,6 +101,7 @@ export async function registerPublicReviewRoutes(fastify) {
text: r.text,
imageUrl: r.imageUrl,
createdAt: r.createdAt,
authorId: r.user?.id ?? r.userId,
authorDisplay: publicReviewAuthorDisplay(r.user),
authorAvatar: r.user?.avatar ?? null,
authorAvatarStyle: r.user?.avatarStyle ?? null,