Skip to content

Commit

Permalink
fix: allow all products on notifs for admins
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannNumericite committed Dec 3, 2024
1 parent 9be555b commit 73a31a6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions webapp-backoffice/src/server/routers/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,14 @@ export const openAPIRouter = router({
...user.adminEntityRights.flatMap((aer) => aer.entity.products.map((p) => p.id))
];

const accessibleProducts = products
.filter((product) => accessibleProductIds.includes(product.productId))
.sort((a, b) => b.reviewCount - a.reviewCount)
.slice(0, 10);
const accessibleProducts = user.role.includes("admin")
? products
.sort((a, b) => b.reviewCount - a.reviewCount)
.slice(0, 10)
: products
.filter((product) => accessibleProductIds.includes(product.productId))
.sort((a, b) => b.reviewCount - a.reviewCount)
.slice(0, 10);

const totalNewReviews = accessibleProducts.reduce((sum, product) => sum + product.reviewCount, 0);

Expand Down

0 comments on commit 73a31a6

Please sign in to comment.