= ({
return grouped;
}, [search.allFacets]);
+ const hvd = "http://data.europa.eu/r5r/applicableLegislation";
+ const national = "http://purl.org/dc/terms/subject";
+
+ const activeCheckboxFilters = useMemo(() => {
+ const filters = [];
+
+ // HVD filter
+ if (search.request.facetValues?.some((t) => t.title === ESRdfType.hvd)) {
+ filters.push({
+ id: "hvd_only",
+ label: t(`resources|${hvd}`),
+ facetValue: search.request.facetValues.find(
+ (t) => t.title === ESRdfType.hvd,
+ ),
+ });
+ }
+
+ // National filter
+ if (
+ search.request.facetValues?.some(
+ (t) => t.facet === ESRdfType.national_data,
+ )
+ ) {
+ filters.push({
+ id: "national_only",
+ label: t(`resources|${national}`),
+ facetValue: search.request.facetValues.find(
+ (t) => t.facet === ESRdfType.national_data,
+ ),
+ });
+ }
+
+ // API only filter
+ if (
+ searchMode === "datasets" &&
+ search.request.esRdfTypes?.some(
+ (t) => t === ESRdfType.esterms_ServedByDataService,
+ ) &&
+ search.request.esRdfTypes?.some(
+ (t) => t === ESRdfType.esterms_IndependentDataService,
+ ) &&
+ !search.request.esRdfTypes?.some((t) => t === ESRdfType.dataset)
+ ) {
+ filters.push({
+ id: "api_only",
+ label: "API",
+ // Special handling for API filter since it uses esRdfTypes
+ isApiFilter: true,
+ });
+ }
+
+ return filters;
+ }, [search.request.facetValues, search.request.esRdfTypes, searchMode]);
+
return (
))}
- {search.request.facetValues && search.request.facetValues.length > 0 && (
-
-
- {(containHVD || containNational) && (
-
- {t("common|active-filters")}:
-
- )}
- {search.request &&
- search.request.facetValues &&
- (search.request.facetValues as SearchFacetValue[]).map(
- (facetValue: SearchFacetValue, index: number) =>
- facetValue.facet !== hvd &&
- facetValue.facet !== national && (
-
-
= 2
- ? "block whitespace-nowrap"
- : "hidden"
- }
- >
-
-
- )}
+
);
};