From a2eb6226a618d0c6881f8fcfa3b31dce087fee26 Mon Sep 17 00:00:00 2001 From: Duncan Ragsdale <88173870+Thistleman@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:31:20 -0700 Subject: [PATCH] resolved devmode bugs, corrected dep array and additional faulty logic Signed-off-by: Duncan Ragsdale <88173870+Thistleman@users.noreply.github.com> --- src/app/(analyses)/analyses/analysis/page.tsx | 20 +++++++++------- .../analyses/leaderboard/leaderboard.tsx | 23 +++++++++++++++++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/app/(analyses)/analyses/analysis/page.tsx b/src/app/(analyses)/analyses/analysis/page.tsx index 80dcfdb..7c4e06a 100644 --- a/src/app/(analyses)/analyses/analysis/page.tsx +++ b/src/app/(analyses)/analyses/analysis/page.tsx @@ -25,8 +25,6 @@ import MS from '@/services/md_service'; // *********** REDUX IMPORTS *********** -import {useDispatch} from 'react-redux'; - // *********** END OF IMPORTS *********** @@ -39,8 +37,6 @@ const AnalysisPage: React.FC = () => { const searchParams = useSearchParams(); const navigate = useRouter(); - const dispatch = useDispatch(); - if (searchParams.get('analysisId') === null) { console.error('Analysis ID not found'); navigate.push('/analyses'); @@ -52,12 +48,19 @@ const AnalysisPage: React.FC = () => { selectedAnalysis !== 'development' ) && ( selectedAnalysis !== null - ) && ( - !isNaN(parseInt(selectedAnalysis)) )) { selectedAnalysis = parseInt( selectedAnalysis.toString() || '', 10); + } else if (( + selectedAnalysis !== null + ) && ( + isNaN(parseInt(selectedAnalysis)) + ) && ( + selectedAnalysis === 'development' + )) { + console.log('Development analysis'); } else { + console.log('NO!', selectedAnalysis); navigate.push('/analyses'); } @@ -83,7 +86,7 @@ const AnalysisPage: React.FC = () => { useEffect(() => { if (window.location.hostname.includes('localhost') && ( - analysisId === 'development' + selectedAnalysis === 'development' )) { setAnalysisDetailsCard({ analysisId: 'development', @@ -112,7 +115,7 @@ const AnalysisPage: React.FC = () => { }); }); } - }, [selectedAnalysis, dispatch, navigate, analysisId, error]); + }, [selectedAnalysis, error, navigate]); useEffect(() => { console.log('analysis', selectedAnalysis, typeof selectedAnalysis); @@ -147,6 +150,7 @@ const AnalysisPage: React.FC = () => { const handleChange = (event: any, newValue: number) => { + console.log('new value:', newValue); setValue(newValue); }; diff --git a/src/app/modules/analyses/leaderboard/leaderboard.tsx b/src/app/modules/analyses/leaderboard/leaderboard.tsx index 5cb497d..839aa7f 100644 --- a/src/app/modules/analyses/leaderboard/leaderboard.tsx +++ b/src/app/modules/analyses/leaderboard/leaderboard.tsx @@ -33,8 +33,27 @@ export default function Leaderboard() { navigate.push('/analyses'); } - const analysisId: string | number = parseInt( - searchParams.get('analysisId') || '', 10); + let analysisId: string | number | null = searchParams.get('analysisId'); + + if (( + analysisId !== 'development' + ) && ( + analysisId !== null + )) { + analysisId = parseInt( + analysisId.toString() || '', 10); + } else if (( + analysisId !== null + ) && ( + isNaN(parseInt(analysisId)) + ) && ( + analysisId === 'development' + )) { + console.log('Development analysis'); + } else { + console.log('NO!', analysisId); + navigate.push('/analyses'); + } const [leaderboardDetails, setLeaderboardDetails] = useState<{ id: number; file_completion: number;