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
@@ -25,6 +25,7 @@ export type PublicReviewFeedItem = {
text: string | null
imageUrl: string | null
createdAt: string
authorId: string
authorDisplay: string
authorAvatar?: string | null
authorAvatarStyle?: string | null
@@ -53,6 +54,7 @@ export type PublicProductReviewItem = {
text: string | null
imageUrl: string | null
createdAt: string
authorId: string
authorDisplay: string
authorAvatar?: string | null
authorAvatarStyle?: string | null
@@ -20,7 +20,7 @@ function ReviewItem({ rv }: { rv: PublicProductReviewItem }) {
<Stack spacing={0.75}>
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
<UserAvatar
userId={rv.authorDisplay}
userId={rv.authorId}
avatarUrl={rv.authorAvatar}
avatarStyle={rv.authorAvatarStyle}
size={32}
@@ -102,7 +102,7 @@ export function ReviewsBlock() {
)}
<Stack direction="row" spacing={1.5} sx={{ minWidth: { sm: 200 }, alignItems: 'center' }}>
<UserAvatar
userId={r.authorDisplay}
userId={r.authorId}
avatarUrl={r.authorAvatar}
avatarStyle={r.authorAvatarStyle}
size={40}
+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,