From b67d824115a4dc53c5615d8320bf2c37ddcc81a6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 16:18:57 +0530 Subject: [PATCH] fix(CE): fixed sync runs on click function --- ui/src/hooks/syncs/useSyncRuns.tsx | 14 ++++++++++++++ .../Activate/Syncs/SyncRuns/SyncRuns.tsx | 19 +++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 ui/src/hooks/syncs/useSyncRuns.tsx diff --git a/ui/src/hooks/syncs/useSyncRuns.tsx b/ui/src/hooks/syncs/useSyncRuns.tsx new file mode 100644 index 00000000..34c72476 --- /dev/null +++ b/ui/src/hooks/syncs/useSyncRuns.tsx @@ -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; diff --git a/ui/src/views/Activate/Syncs/SyncRuns/SyncRuns.tsx b/ui/src/views/Activate/Syncs/SyncRuns/SyncRuns.tsx index 9029ec05..cd57fa59 100644 --- a/ui/src/views/Activate/Syncs/SyncRuns/SyncRuns.tsx +++ b/ui/src/views/Activate/Syncs/SyncRuns/SyncRuns.tsx @@ -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(); @@ -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) => { + navigate(`run/${row.original.id}`); }; const syncList = data?.data;