1
- import { useQuery } from '@tanstack/react-query' ;
2
1
import { useNavigate , useParams , useSearchParams } from 'react-router-dom' ;
3
- import { getSyncRunsBySyncId } from '@/services/syncs' ;
4
2
import { useMemo , useState , useEffect } from 'react' ;
5
3
import { Box } from '@chakra-ui/react' ;
6
4
import Loader from '@/components/Loader' ;
7
5
import Pagination from '@/components/Pagination' ;
6
+ import { useStore } from '@/stores' ;
7
+ import useSyncRuns from '@/hooks/syncs/useSyncRuns' ;
8
8
import { SyncRunsColumns } from './SyncRunsColumns' ;
9
9
import DataTable from '@/components/DataTable' ;
10
+ import { Row } from '@tanstack/react-table' ;
11
+ import { SyncRunsResponse } from '../types' ;
10
12
import RowsNotFound from '@/components/DataTable/RowsNotFound' ;
11
13
12
14
const SyncRuns = ( ) => {
15
+ const activeWorkspaceId = useStore ( ( state ) => state . workspaceId ) ;
16
+
13
17
const { syncId } = useParams ( ) ;
14
18
const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
15
19
const navigate = useNavigate ( ) ;
@@ -21,15 +25,10 @@ const SyncRuns = () => {
21
25
setSearchParams ( { page : currentPage . toString ( ) } ) ;
22
26
} , [ currentPage , setSearchParams ] ) ;
23
27
24
- const { data, isLoading } = useQuery ( {
25
- queryKey : [ 'activate' , 'sync-runs' , syncId , 'page-' + currentPage ] ,
26
- queryFn : ( ) => getSyncRunsBySyncId ( syncId as string , currentPage . toString ( ) ) ,
27
- refetchOnMount : true ,
28
- refetchOnWindowFocus : false ,
29
- } ) ;
28
+ const { data, isLoading } = useSyncRuns ( syncId as string , currentPage , activeWorkspaceId ) ;
30
29
31
- const handleOnSyncClick = ( row : Record < 'id' , string > ) => {
32
- navigate ( `run/${ row . id } ` ) ;
30
+ const handleOnSyncClick = ( row : Row < SyncRunsResponse > ) => {
31
+ navigate ( `run/${ row . original . id } ` ) ;
33
32
} ;
34
33
35
34
const syncList = data ?. data ;
0 commit comments