fix: review avatar uses authorId instead of displayName, show reviews for hidden products
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user