From a169a39edd44b9b94342929ffb0a145e6dc2645a Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Tue, 6 May 2025 11:39:11 +0200 Subject: [PATCH] Update routing and components to handle activePgroup in URLs Modified navigation to include activePgroup as a query parameter. Updated ResultsView, SampleTracker, and ResultGrid components to utilize activePgroup for contextual filtering based on the URL. This ensures proper grouping and improved parameter handling across the application. --- frontend/src/components/BeamtimeOverview.tsx | 2 +- frontend/src/components/ResultGrid.tsx | 1 - frontend/src/pages/ResultsView.tsx | 9 ++++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/BeamtimeOverview.tsx b/frontend/src/components/BeamtimeOverview.tsx index b1032dc..9c8d01c 100644 --- a/frontend/src/components/BeamtimeOverview.tsx +++ b/frontend/src/components/BeamtimeOverview.tsx @@ -119,7 +119,7 @@ const BeamtimeOverview: React.FC = ({ activePgroup }) => // Navigate to the ResultsView page for the selected beamtime const handleViewResults = (beamtimeId: number) => { - navigate(`/results/${beamtimeId}`); // Pass the beamtimeId in the URL + navigate(`/results/${beamtimeId}?pgroup=${activePgroup}`); }; return ( diff --git a/frontend/src/components/ResultGrid.tsx b/frontend/src/components/ResultGrid.tsx index 3a0ebf9..a67b3eb 100644 --- a/frontend/src/components/ResultGrid.tsx +++ b/frontend/src/components/ResultGrid.tsx @@ -13,7 +13,6 @@ import HourglassEmptyIcon from '@mui/icons-material/HourglassEmpty'; - // Extend your image info interface if needed. interface ImageInfo { id: number; diff --git a/frontend/src/pages/ResultsView.tsx b/frontend/src/pages/ResultsView.tsx index 46e1929..b94ef64 100644 --- a/frontend/src/pages/ResultsView.tsx +++ b/frontend/src/pages/ResultsView.tsx @@ -1,13 +1,16 @@ import React from 'react'; -import { useParams } from 'react-router-dom'; +import { useParams, useSearchParams} from 'react-router-dom'; import SampleTracker from '../components/SampleTracker'; import ResultGrid from '../components/ResultGrid'; + interface ResultsViewProps {} const ResultsView: React.FC = () => { // Get the selected beamtime ID from the URL const { beamtimeId } = useParams(); + const [searchParams] = useSearchParams(); + const activePgroup = searchParams.get("pgroup") ?? ''; return (
@@ -15,8 +18,8 @@ const ResultsView: React.FC = () => {

Results for Beamtime ID: {beamtimeId}

{/* Use the beamtimeId to filter or query specific results */} - - + +
); };