1+ 'use client'
2+
13import React , { useEffect , useReducer , useRef , useState } from 'react' ;
24import Image from 'next/image' ;
35import { useRouter } from 'next/navigation' ;
@@ -20,6 +22,7 @@ import { Icons } from '@/components/icons';
2022import { Loading } from '@/components/loading' ;
2123import Filter from '../datasets/components/FIlter/Filter' ;
2224import Styles from '../datasets/dataset.module.scss' ;
25+ import { fetchData } from '@/fetch' ;
2326
2427// Interfaces
2528interface Bucket {
@@ -185,11 +188,7 @@ const useUrlParams = (
185188
186189// Listing Component Props
187190interface ListingProps {
188- fetchDatasets : ( variables : string ) => Promise < {
189- results : any [ ] ;
190- total : number ;
191- aggregations : Aggregations ;
192- } > ;
191+ type : string ;
193192 breadcrumbData ?: { href : string ; label : string } [ ] ;
194193 headerComponent ?: React . ReactNode ;
195194 categoryName ?: string ;
@@ -200,7 +199,7 @@ interface ListingProps {
200199}
201200
202201const ListingComponent : React . FC < ListingProps > = ( {
203- fetchDatasets ,
202+ type ,
204203 breadcrumbData,
205204 headerComponent,
206205 categoryName,
@@ -229,7 +228,7 @@ const ListingComponent: React.FC<ListingProps> = ({
229228 if ( variables ) {
230229 const currentFetchId = ++ latestFetchId . current ;
231230
232- fetchDatasets ( variables )
231+ fetchData ( type , variables )
233232 . then ( ( res ) => {
234233 // Only set if this is the latest call
235234 if ( currentFetchId === latestFetchId . current ) {
@@ -240,7 +239,7 @@ const ListingComponent: React.FC<ListingProps> = ({
240239 console . error ( err ) ;
241240 } ) ;
242241 }
243- } , [ variables , fetchDatasets ] ) ;
242+ } , [ variables , type ] ) ;
244243
245244 const [ hasMounted , setHasMounted ] = useState ( false ) ;
246245
0 commit comments