Skip to content

Commit 15ef151

Browse files
committed
Added integration of jobs to quizzes
1 parent 36b0145 commit 15ef151

2 files changed

Lines changed: 39 additions & 10 deletions

File tree

nextstep-frontend/src/components/LinkedInIntegration.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react';
22
import { Box, Typography, Button, Grid, CircularProgress, IconButton, TextField, MenuItem, Select, FormControl, InputLabel, Dialog, DialogTitle, DialogContent, DialogActions, Chip, Stack } from '@mui/material';
33
import { ExpandLess, LinkedIn, Settings } from '@mui/icons-material';
4+
import { useNavigate } from 'react-router-dom';
45

56
interface Job {
67
position: string;
@@ -68,6 +69,12 @@ const LinkedInIntegration: React.FC<LinkedInIntegrationProps> = ({
6869
setJobDetails(null);
6970
};
7071

72+
const handleGenerateQuiz = (job: Job) => {
73+
const subject = `${job.position} at ${job.company}`;
74+
const quizUrl = `/quiz?subject=${encodeURIComponent(subject)}`;
75+
window.open(quizUrl, '_blank');
76+
};
77+
7178
return (
7279
<Box sx={{ bgcolor: 'background.paper', p: 3, borderRadius: 2, boxShadow: 1, mt: 4 }}>
7380
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
@@ -281,14 +288,22 @@ const LinkedInIntegration: React.FC<LinkedInIntegrationProps> = ({
281288
Close
282289
</Button>
283290
{selectedJob?.jobUrl && (
284-
<Button
285-
href={selectedJob.jobUrl}
286-
target="_blank"
287-
rel="noopener noreferrer"
288-
color="primary"
289-
>
290-
Open in LinkedIn
291-
</Button>
291+
<div>
292+
<Button
293+
onClick={() => handleGenerateQuiz(selectedJob)}
294+
color="primary"
295+
>
296+
Generate a quiz
297+
</Button>
298+
<Button
299+
href={selectedJob.jobUrl}
300+
target="_blank"
301+
rel="noopener noreferrer"
302+
color="primary"
303+
>
304+
Open in LinkedIn
305+
</Button>
306+
</div>
292307
)}
293308
</DialogActions>
294309
</Dialog>

nextstep-frontend/src/pages/Quiz.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react';
2+
import { useSearchParams } from 'react-router-dom';
23
import {
34
Container,
45
Box,
@@ -102,7 +103,8 @@ interface QuizState {
102103
}
103104

104105
const Quiz: React.FC = () => {
105-
const [subject, setSubject] = useState<string>('');
106+
const [searchParams] = useSearchParams();
107+
const [subject, setSubject] = useState<string>(searchParams.get('subject') || '');
106108
const [quiz, setQuiz] = useState<QuizState | null>(null);
107109
const [loading, setLoading] = useState<boolean>(false);
108110
const [showAnswer, setShowAnswer] = useState<{ [key: number]: boolean }>({});
@@ -218,6 +220,11 @@ const Quiz: React.FC = () => {
218220
}
219221
};
220222

223+
const handleEditSubject = (newSubject: string) => {
224+
setSubject(newSubject);
225+
setQuiz(null); // Reset the quiz to allow generating a new one with the updated subject
226+
};
227+
221228
return (
222229
<Container maxWidth="md" sx={{ py: 4 }}>
223230
<Typography variant="h4" component="h1" gutterBottom align="center">
@@ -254,7 +261,14 @@ const Quiz: React.FC = () => {
254261
{quiz && (
255262
<Box sx={{ p: 3, bgcolor: 'background.paper', borderRadius: 2, boxShadow: 1 }}>
256263
<Typography variant="h5" gutterBottom align="center" sx={{ mb: 3 }}>
257-
Quiz on: {quiz.subject}
264+
Quiz on:
265+
<TextField
266+
value={subject}
267+
onChange={(e) => handleEditSubject(e.target.value)}
268+
variant="outlined"
269+
size="small"
270+
sx={{ ml: 2, width: '50%' }}
271+
/>
258272
</Typography>
259273

260274
{/* --- Enhanced Display of Quiz Metadata --- */}

0 commit comments

Comments
 (0)