diff --git a/frontend/src/components/ResultGrid.tsx b/frontend/src/components/ResultGrid.tsx index c11af32..586b3ea 100644 --- a/frontend/src/components/ResultGrid.tsx +++ b/frontend/src/components/ResultGrid.tsx @@ -49,17 +49,29 @@ const ResultGrid: React.FC = ({ activePgroup }) => { }, []); useEffect(() => { - console.log("Fetching sample results for active_pgroup:", activePgroup); - SamplesService.getSampleResultsSamplesResultsGet(activePgroup) - .then((response: SampleResult[]) => { - console.log("Response received:", response); - setRows(response); - }) - .catch((err: Error) => { - console.error('Error fetching sample results:', err); - }); + const fetchData = () => { + console.log("Fetching sample results for active_pgroup:", activePgroup); + SamplesService.getSampleResultsSamplesResultsGet(activePgroup) + .then((response: SampleResult[]) => { + console.log("Response received:", response); + setRows(response); + }) + .catch((err: Error) => { + console.error("Error fetching sample results:", err); + }); + }; + + // Fetch data initially. + fetchData(); + + // Set up an interval to refresh data every 15 seconds (adjust as needed) + const intervalId = setInterval(fetchData, 15000); + + // Clean up when component unmounts or activePgroup changes. + return () => clearInterval(intervalId); }, [activePgroup]); + const columns: GridColDef[] = [ { field: 'sample_id', headerName: 'ID', width: 70 }, { field: 'sample_name', headerName: 'Sample Name', width: 150 },