From 2ea185b710959ff83331da1ae4c9b158c8ef2cb9 Mon Sep 17 00:00:00 2001 From: Demenech Date: Tue, 9 Apr 2024 17:41:01 -0300 Subject: [PATCH] feat: Catalog component API and docs improvements --- .../components/src/components/Catalog.tsx | 20 ++--- .../components/stories/Catalog.stories.ts | 75 ++----------------- 2 files changed, 17 insertions(+), 78 deletions(-) diff --git a/packages/components/src/components/Catalog.tsx b/packages/components/src/components/Catalog.tsx index 83899ec2..a7b63dc5 100644 --- a/packages/components/src/components/Catalog.tsx +++ b/packages/components/src/components/Catalog.tsx @@ -7,7 +7,12 @@ export function Catalog({ datasets, facets, }: { - datasets: any[]; + datasets: { + _id: string | number; + metadata: { title: string; [k: string]: string | number }; + url_path: string; + [k: string]: any; + }[]; facets: string[]; }) { const [indexFilter, setIndexFilter] = useState(''); @@ -56,7 +61,7 @@ export function Catalog({ //Then check if the selectedValue for the given facet is included in the dataset metadata .filter((dataset) => { //Avoids a server rendering breakage - if (!watch() || Object.keys(watch()).length === 0) return true + if (!watch() || Object.keys(watch()).length === 0) return true; //This will filter only the key pairs of the metadata values that were selected as facets const datasetFacets = Object.entries(dataset.metadata).filter((entry) => facets.includes(entry[0]) @@ -86,9 +91,7 @@ export function Catalog({ className="p-2 ml-1 text-sm shadow border border-block" {...register(elem[0] + '.selectedValue')} > - + {(elem[1] as { possibleValues: string[] }).possibleValues.map( (val) => (