refactor: add conditional brand filter counts
This commit is contained in:
parent
d8bbb35228
commit
cac55f1805
|
|
@ -54,7 +54,13 @@ export const getTotalBrandAnalysis = async () => {
|
||||||
brand: true,
|
brand: true,
|
||||||
_count: {
|
_count: {
|
||||||
select: {
|
select: {
|
||||||
reviews: true,
|
reviews: {
|
||||||
|
where: {
|
||||||
|
user: {
|
||||||
|
email: session.user.email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ export function BrandFilter() {
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{brands.map((brand) => {
|
{brands.map((brand) => {
|
||||||
|
if (brand.count === 0) return null;
|
||||||
|
|
||||||
const isActive =
|
const isActive =
|
||||||
selectedBrand?.toLowerCase() === brand.name.toLowerCase();
|
selectedBrand?.toLowerCase() === brand.name.toLowerCase();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue