diff --git a/nextstep-frontend/src/components/LinkedInIntegration.tsx b/nextstep-frontend/src/components/LinkedInIntegration.tsx index a5e0929..c13e7d5 100644 --- a/nextstep-frontend/src/components/LinkedInIntegration.tsx +++ b/nextstep-frontend/src/components/LinkedInIntegration.tsx @@ -68,6 +68,12 @@ const LinkedInIntegration: React.FC = ({ setJobDetails(null); }; + const handleGenerateQuiz = (job: Job) => { + const subject = `${job.position} at ${job.company}`; + const quizUrl = `/quiz?subject=${encodeURIComponent(subject)}`; + window.open(quizUrl, '_blank'); + }; + return ( @@ -281,14 +287,22 @@ const LinkedInIntegration: React.FC = ({ Close {selectedJob?.jobUrl && ( - +
+ + +
)} diff --git a/nextstep-frontend/src/pages/Quiz.tsx b/nextstep-frontend/src/pages/Quiz.tsx index be0029b..6847b32 100644 --- a/nextstep-frontend/src/pages/Quiz.tsx +++ b/nextstep-frontend/src/pages/Quiz.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useSearchParams } from 'react-router-dom'; import { Container, Box, @@ -26,6 +27,7 @@ import { BusinessOutlined as BusinessOutlinedIcon, LocalOfferOutlined as LocalOfferOutlinedIcon, } from '@mui/icons-material'; +import SchoolIcon from '@mui/icons-material/School'; // Import graduation hat icon import api from '../serverApi'; import { config } from '../config'; @@ -102,7 +104,8 @@ interface QuizState { } const Quiz: React.FC = () => { - const [subject, setSubject] = useState(''); + const [searchParams] = useSearchParams(); + const [subject, setSubject] = useState(searchParams.get('subject') || ''); const [quiz, setQuiz] = useState(null); const [loading, setLoading] = useState(false); const [showAnswer, setShowAnswer] = useState<{ [key: number]: boolean }>({}); @@ -218,10 +221,29 @@ const Quiz: React.FC = () => { } }; + const handleEditSubject = (newSubject: string) => { + setSubject(newSubject); + setQuiz(null); // Reset the quiz to allow generating a new one with the updated subject + }; + return ( - - Quiz Generator & Grader + + Quiz Generator &{' '} + + + Grader + {/* Subject Input */} @@ -254,7 +276,14 @@ const Quiz: React.FC = () => { {quiz && ( - Quiz on: {quiz.subject} + Quiz on: + handleEditSubject(e.target.value)} + variant="outlined" + size="small" + sx={{ ml: 2, width: '50%' }} + /> {/* --- Enhanced Display of Quiz Metadata --- */}