diff --git a/src/app/page.js b/src/app/page.js index 5a820dc..dbbb041 100644 --- a/src/app/page.js +++ b/src/app/page.js @@ -11,6 +11,26 @@ const Page = () => { const [globalScore, setGlobalScore] = useState(0); const [overallGrade, setOverallGrade] = useState(''); + useEffect(() => { + const queryParams = new URLSearchParams(window.location.search); + const token = queryParams.get('token'); + if (token) { + // Load selected qualification and grades from token in URL + const parsedToken = JSON.parse(atob(token)); + setSelectedQualification(parsedToken.qualification); + setSelectedGrades(parsedToken.grades); + } + }, []); + + + useEffect(() => { + // Save selected qualification and grades to URL + if (selectedQualification) { + const token = btoa(JSON.stringify({ qualification: selectedQualification, grades: selectedGrades })); + window.history.replaceState(null, '', `?token=${token}`); + } + }, [selectedQualification, selectedGrades]); + useEffect(() => { if (!selectedQualification) return; // Do nothing if no qualification is selected