11'use client'
22
3- import React , { useEffect , useReducer , useRef , useState } from 'react ' ;
3+ import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination ' ;
44import Image from 'next/image' ;
55import { useRouter } from 'next/navigation' ;
6- import GraphqlPagination from '@/app/[locale]/dashboard/components/GraphqlPagination/graphqlPagination' ;
76import {
87 Button ,
98 ButtonGroup ,
@@ -15,14 +14,15 @@ import {
1514 Text ,
1615 Tray ,
1716} from 'opub-ui' ;
17+ import React , { useEffect , useReducer , useRef , useState } from 'react' ;
1818
19- import { cn , formatDate } from '@/lib/utils' ;
2019import BreadCrumbs from '@/components/BreadCrumbs' ;
2120import { Icons } from '@/components/icons' ;
2221import { Loading } from '@/components/loading' ;
22+ import { fetchData } from '@/fetch' ;
23+ import { cn , formatDate } from '@/lib/utils' ;
2324import Filter from '../datasets/components/FIlter/Filter' ;
2425import Styles from '../datasets/dataset.module.scss' ;
25- import { fetchData } from '@/fetch' ;
2626
2727// Interfaces
2828interface Bucket {
@@ -281,12 +281,19 @@ const ListingComponent: React.FC<ListingProps> = ({
281281
282282 const filterOptions = Object . entries ( aggregations ) . reduce (
283283 ( acc : Record < string , { label : string ; value : string } [ ] > , [ key , value ] ) => {
284- // Check if value exists and has buckets array
284+ // Check if value exists and has buckets array (Elasticsearch format)
285285 if ( value && value . buckets && Array . isArray ( value . buckets ) ) {
286286 acc [ key ] = value . buckets . map ( ( bucket ) => ( {
287287 label : bucket . key ,
288288 value : bucket . key ,
289289 } ) ) ;
290+ }
291+ // Handle key-value object format (current backend format)
292+ else if ( value && typeof value === 'object' && ! Array . isArray ( value ) ) {
293+ acc [ key ] = Object . entries ( value ) . map ( ( [ label , count ] ) => ( {
294+ label : label ,
295+ value : label ,
296+ } ) ) ;
290297 }
291298 return acc ;
292299 } ,
0 commit comments