fix: review avatar uses authorId instead of displayName, show reviews for hidden products
This commit is contained in:
@@ -25,6 +25,7 @@ export type PublicReviewFeedItem = {
|
|||||||
text: string | null
|
text: string | null
|
||||||
imageUrl: string | null
|
imageUrl: string | null
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
authorId: string
|
||||||
authorDisplay: string
|
authorDisplay: string
|
||||||
authorAvatar?: string | null
|
authorAvatar?: string | null
|
||||||
authorAvatarStyle?: string | null
|
authorAvatarStyle?: string | null
|
||||||
@@ -53,6 +54,7 @@ export type PublicProductReviewItem = {
|
|||||||
text: string | null
|
text: string | null
|
||||||
imageUrl: string | null
|
imageUrl: string | null
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
authorId: string
|
||||||
authorDisplay: string
|
authorDisplay: string
|
||||||
authorAvatar?: string | null
|
authorAvatar?: string | null
|
||||||
authorAvatarStyle?: string | null
|
authorAvatarStyle?: string | null
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function ReviewItem({ rv }: { rv: PublicProductReviewItem }) {
|
|||||||
<Stack spacing={0.75}>
|
<Stack spacing={0.75}>
|
||||||
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
|
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
userId={rv.authorDisplay}
|
userId={rv.authorId}
|
||||||
avatarUrl={rv.authorAvatar}
|
avatarUrl={rv.authorAvatar}
|
||||||
avatarStyle={rv.authorAvatarStyle}
|
avatarStyle={rv.authorAvatarStyle}
|
||||||
size={32}
|
size={32}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export function ReviewsBlock() {
|
|||||||
)}
|
)}
|
||||||
<Stack direction="row" spacing={1.5} sx={{ minWidth: { sm: 200 }, alignItems: 'center' }}>
|
<Stack direction="row" spacing={1.5} sx={{ minWidth: { sm: 200 }, alignItems: 'center' }}>
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
userId={r.authorDisplay}
|
userId={r.authorId}
|
||||||
avatarUrl={r.authorAvatar}
|
avatarUrl={r.authorAvatar}
|
||||||
avatarStyle={r.authorAvatarStyle}
|
avatarStyle={r.authorAvatarStyle}
|
||||||
size={40}
|
size={40}
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ export async function registerPublicReviewRoutes(fastify) {
|
|||||||
const take = Math.min(parsed, 5)
|
const take = Math.min(parsed, 5)
|
||||||
|
|
||||||
const rows = await prisma.review.findMany({
|
const rows = await prisma.review.findMany({
|
||||||
where: { status: 'approved', product: { published: true } },
|
where: { status: 'approved' },
|
||||||
include: {
|
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 } },
|
product: { select: { id: true, title: true, published: true, slug: true } },
|
||||||
},
|
},
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
@@ -53,6 +53,7 @@ export async function registerPublicReviewRoutes(fastify) {
|
|||||||
text: r.text,
|
text: r.text,
|
||||||
imageUrl: r.imageUrl,
|
imageUrl: r.imageUrl,
|
||||||
createdAt: r.createdAt,
|
createdAt: r.createdAt,
|
||||||
|
authorId: r.user?.id ?? r.userId,
|
||||||
authorDisplay: publicReviewAuthorDisplay(r.user),
|
authorDisplay: publicReviewAuthorDisplay(r.user),
|
||||||
authorAvatar: r.user?.avatar ?? null,
|
authorAvatar: r.user?.avatar ?? null,
|
||||||
authorAvatarStyle: r.user?.avatarStyle ?? null,
|
authorAvatarStyle: r.user?.avatarStyle ?? null,
|
||||||
@@ -87,7 +88,7 @@ export async function registerPublicReviewRoutes(fastify) {
|
|||||||
const rawItems = await prisma.review.findMany({
|
const rawItems = await prisma.review.findMany({
|
||||||
where,
|
where,
|
||||||
include: {
|
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' },
|
orderBy: { createdAt: 'desc' },
|
||||||
skip: (page - 1) * pageSize,
|
skip: (page - 1) * pageSize,
|
||||||
@@ -100,6 +101,7 @@ export async function registerPublicReviewRoutes(fastify) {
|
|||||||
text: r.text,
|
text: r.text,
|
||||||
imageUrl: r.imageUrl,
|
imageUrl: r.imageUrl,
|
||||||
createdAt: r.createdAt,
|
createdAt: r.createdAt,
|
||||||
|
authorId: r.user?.id ?? r.userId,
|
||||||
authorDisplay: publicReviewAuthorDisplay(r.user),
|
authorDisplay: publicReviewAuthorDisplay(r.user),
|
||||||
authorAvatar: r.user?.avatar ?? null,
|
authorAvatar: r.user?.avatar ?? null,
|
||||||
authorAvatarStyle: r.user?.avatarStyle ?? null,
|
authorAvatarStyle: r.user?.avatarStyle ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user