@@ -32,7 +32,6 @@ import {
3232 deleteJobs ,
3333 getJobHistory ,
3434 killJobs ,
35- refreshJobs ,
3635 rescheduleJobs ,
3736 useJobs ,
3837} from "./jobDataService" ;
@@ -107,21 +106,22 @@ export function JobDataTable({
107106 // State for job history
108107 const [ isHistoryDialogOpen , setIsHistoryDialogOpen ] = useState ( false ) ;
109108 const [ jobHistoryData , setJobHistoryData ] = useState < JobHistory [ ] > ( [ ] ) ;
110-
111109 /**
112110 * Fetches the jobs from the /api/jobs/search endpoint
113111 */
114- const { data, error, isLoading, isValidating } = useJobs (
112+ const {
113+ data : results ,
114+ headers : dataHeader ,
115+ error : dataError ,
116+ isLoading,
117+ } = useJobs (
115118 diracxUrl ,
116119 accessToken ,
117120 searchBody ,
118121 pagination . pageIndex ,
119122 pagination . pageSize ,
120123 ) ;
121124
122- const dataHeader = data ?. headers ;
123- const results = useMemo ( ( ) => data ?. data || [ ] , [ data ?. data ] ) ;
124-
125125 // Parse the headers to get the first item, last item and number of items
126126 const contentRange = dataHeader ?. get ( "content-range" ) ;
127127 let totalJobs = 0 ;
@@ -146,13 +146,10 @@ export function JobDataTable({
146146 const selectedIds = Object . keys ( rowSelection ) . map ( Number ) ;
147147 await deleteJobs ( diracxUrl , selectedIds , accessToken ) ;
148148 setBackdropOpen ( false ) ;
149- refreshJobs (
150- diracxUrl ,
151- accessToken ,
152- searchBody ,
153- pagination . pageIndex ,
154- pagination . pageSize ,
155- ) ;
149+ // Refresh the data manually
150+ setSearchBody ( ( prev ) => {
151+ return { ...prev } ;
152+ } ) ;
156153 clearSelected ( ) ;
157154 setSnackbarInfo ( {
158155 open : true ,
@@ -199,13 +196,12 @@ export function JobDataTable({
199196 ) ;
200197
201198 setBackdropOpen ( false ) ;
202- refreshJobs (
203- diracxUrl ,
204- accessToken ,
205- searchBody ,
206- pagination . pageIndex ,
207- pagination . pageSize ,
208- ) ;
199+
200+ // Refresh the data manually
201+ setSearchBody ( ( prev ) => {
202+ return { ...prev } ;
203+ } ) ;
204+
209205 clearSelected ( ) ;
210206 // Handle Snackbar Messaging
211207 if ( successfulJobs . length > 0 && failedJobs . length > 0 ) {
@@ -271,13 +267,10 @@ export function JobDataTable({
271267 ) ;
272268
273269 setBackdropOpen ( false ) ;
274- refreshJobs (
275- diracxUrl ,
276- accessToken ,
277- searchBody ,
278- pagination . pageIndex ,
279- pagination . pageSize ,
280- ) ;
270+ // Refresh the data manually
271+ setSearchBody ( ( prev ) => {
272+ return { ...prev } ;
273+ } ) ;
281274 clearSelected ( ) ;
282275 // Handle Snackbar Messaging
283276 if ( successfulJobs . length > 0 && failedJobs . length > 0 ) {
@@ -405,7 +398,7 @@ export function JobDataTable({
405398 * Table instance
406399 */
407400 const table = useReactTable ( {
408- data : results ,
401+ data : results || [ ] ,
409402 columns,
410403 state : {
411404 columnVisibility,
@@ -443,9 +436,8 @@ export function JobDataTable({
443436 totalRows = { totalJobs }
444437 searchBody = { searchBody }
445438 setSearchBody = { setSearchBody }
446- error = { error }
439+ error = { dataError }
447440 isLoading = { isLoading }
448- isValidating = { isValidating }
449441 toolbarComponents = { toolbarComponents }
450442 menuItems = { menuItems }
451443 />
0 commit comments