forked from potsda.mn/mobilizon
Merge branch 'no-single-promoted-category' into 'main'
Remove promoted categories if there is only one category See merge request framasoft/mobilizon!1568
This commit is contained in:
commit
4821bfc984
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<section
|
<section
|
||||||
|
v-if="promotedCategories.length > 1"
|
||||||
class="mx-auto container flex flex-wrap items-center justify-center gap-3 md:gap-5 my-3"
|
class="mx-auto container flex flex-wrap items-center justify-center gap-3 md:gap-5 my-3"
|
||||||
>
|
>
|
||||||
<CategoryCard
|
<CategoryCard
|
||||||
|
@ -10,7 +11,6 @@
|
||||||
:imageLazy="false"
|
:imageLazy="false"
|
||||||
/>
|
/>
|
||||||
<router-link
|
<router-link
|
||||||
v-if="promotedCategories.length > 0"
|
|
||||||
:to="{ name: RouteName.CATEGORIES }"
|
:to="{ name: RouteName.CATEGORIES }"
|
||||||
class="flex items-end brightness-85 h-36 w-36 md:h-52 md:w-52 rounded-lg font-semibold text-lg md:text-xl p-4 text-white bg-gradient-to-r from-pink-500 via-red-500 to-yellow-500 hover:text-slate-200"
|
class="flex items-end brightness-85 h-36 w-36 md:h-52 md:w-52 rounded-lg font-semibold text-lg md:text-xl p-4 text-white bg-gradient-to-r from-pink-500 via-red-500 to-yellow-500 hover:text-slate-200"
|
||||||
>
|
>
|
||||||
|
@ -47,13 +47,17 @@ const eventCategoryLabel = (categoryId: string): string | undefined => {
|
||||||
return eventCategories.value?.find(({ id }) => categoryId == id)?.label;
|
return eventCategories.value?.find(({ id }) => categoryId == id)?.label;
|
||||||
};
|
};
|
||||||
|
|
||||||
const promotedCategories = computed((): CategoryStatsModel[] => {
|
const promotedCategories = computed((): CategoryStatsModel[] | null => {
|
||||||
return shuffle(
|
const relevant_categories = categoryStats.value.filter(
|
||||||
categoryStats.value.filter(
|
|
||||||
({ key, number }) =>
|
({ key, number }) =>
|
||||||
key !== "MEETING" && number >= 1 && categoriesWithPictures.includes(key)
|
key !== "MEETING" && number >= 1 && categoriesWithPictures.includes(key)
|
||||||
)
|
);
|
||||||
)
|
|
||||||
|
if (relevant_categories.length <= 1) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return shuffle(relevant_categories)
|
||||||
.map(({ key, number }) => ({
|
.map(({ key, number }) => ({
|
||||||
key,
|
key,
|
||||||
number,
|
number,
|
||||||
|
|
Loading…
Reference in a new issue