Skip to content

Commit

Permalink
fix(CE): fixed sync runs on click function
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 5, 2024
1 parent 0cf9c09 commit b67d824
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
14 changes: 14 additions & 0 deletions ui/src/hooks/syncs/useSyncRuns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useQuery } from '@tanstack/react-query';
import { getSyncRunsBySyncId } from '@/services/syncs';

const useSyncRuns = (syncId: string, currentPage: number, activeWorkspaceId: number) => {
return useQuery({
queryKey: ['activate', 'sync-runs', syncId, 'page-' + currentPage, activeWorkspaceId],
queryFn: () => getSyncRunsBySyncId(syncId, currentPage.toString()),
refetchOnMount: true,
refetchOnWindowFocus: false,
enabled: activeWorkspaceId > 0,
});
};

export default useSyncRuns;
19 changes: 9 additions & 10 deletions ui/src/views/Activate/Syncs/SyncRuns/SyncRuns.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { useQuery } from '@tanstack/react-query';
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
import { getSyncRunsBySyncId } from '@/services/syncs';
import { useMemo, useState, useEffect } from 'react';
import { Box } from '@chakra-ui/react';
import Loader from '@/components/Loader';
import Pagination from '@/components/Pagination';
import { useStore } from '@/stores';
import useSyncRuns from '@/hooks/syncs/useSyncRuns';
import { SyncRunsColumns } from './SyncRunsColumns';
import DataTable from '@/components/DataTable';
import { Row } from '@tanstack/react-table';
import { SyncRunsResponse } from '../types';
import RowsNotFound from '@/components/DataTable/RowsNotFound';

const SyncRuns = () => {
const activeWorkspaceId = useStore((state) => state.workspaceId);

const { syncId } = useParams();
const [searchParams, setSearchParams] = useSearchParams();
const navigate = useNavigate();
Expand All @@ -21,15 +25,10 @@ const SyncRuns = () => {
setSearchParams({ page: currentPage.toString() });
}, [currentPage, setSearchParams]);

const { data, isLoading } = useQuery({
queryKey: ['activate', 'sync-runs', syncId, 'page-' + currentPage],
queryFn: () => getSyncRunsBySyncId(syncId as string, currentPage.toString()),
refetchOnMount: true,
refetchOnWindowFocus: false,
});
const { data, isLoading } = useSyncRuns(syncId as string, currentPage, activeWorkspaceId);

const handleOnSyncClick = (row: Record<'id', string>) => {
navigate(`run/${row.id}`);
const handleOnSyncClick = (row: Row<SyncRunsResponse>) => {
navigate(`run/${row.original.id}`);
};

const syncList = data?.data;
Expand Down

0 comments on commit b67d824

Please sign in to comment.