Skip to content

Commit b67d824

Browse files
fix(CE): fixed sync runs on click function
1 parent 0cf9c09 commit b67d824

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

ui/src/hooks/syncs/useSyncRuns.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { useQuery } from '@tanstack/react-query';
2+
import { getSyncRunsBySyncId } from '@/services/syncs';
3+
4+
const useSyncRuns = (syncId: string, currentPage: number, activeWorkspaceId: number) => {
5+
return useQuery({
6+
queryKey: ['activate', 'sync-runs', syncId, 'page-' + currentPage, activeWorkspaceId],
7+
queryFn: () => getSyncRunsBySyncId(syncId, currentPage.toString()),
8+
refetchOnMount: true,
9+
refetchOnWindowFocus: false,
10+
enabled: activeWorkspaceId > 0,
11+
});
12+
};
13+
14+
export default useSyncRuns;

ui/src/views/Activate/Syncs/SyncRuns/SyncRuns.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
import { useQuery } from '@tanstack/react-query';
21
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
3-
import { getSyncRunsBySyncId } from '@/services/syncs';
42
import { useMemo, useState, useEffect } from 'react';
53
import { Box } from '@chakra-ui/react';
64
import Loader from '@/components/Loader';
75
import Pagination from '@/components/Pagination';
6+
import { useStore } from '@/stores';
7+
import useSyncRuns from '@/hooks/syncs/useSyncRuns';
88
import { SyncRunsColumns } from './SyncRunsColumns';
99
import DataTable from '@/components/DataTable';
10+
import { Row } from '@tanstack/react-table';
11+
import { SyncRunsResponse } from '../types';
1012
import RowsNotFound from '@/components/DataTable/RowsNotFound';
1113

1214
const SyncRuns = () => {
15+
const activeWorkspaceId = useStore((state) => state.workspaceId);
16+
1317
const { syncId } = useParams();
1418
const [searchParams, setSearchParams] = useSearchParams();
1519
const navigate = useNavigate();
@@ -21,15 +25,10 @@ const SyncRuns = () => {
2125
setSearchParams({ page: currentPage.toString() });
2226
}, [currentPage, setSearchParams]);
2327

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);
3029

31-
const handleOnSyncClick = (row: Record<'id', string>) => {
32-
navigate(`run/${row.id}`);
30+
const handleOnSyncClick = (row: Row<SyncRunsResponse>) => {
31+
navigate(`run/${row.original.id}`);
3332
};
3433

3534
const syncList = data?.data;

0 commit comments

Comments
 (0)