Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add qr code to home page #8

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-qr-code": "^2.0.15",
"react-router-dom": "^6.27.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/components/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import {
FormControl,
Stack,
Alert,
Box,
} from '@mui/material';
import { useNavigate } from 'react-router-dom';
import QRCode from 'react-qr-code';

function HomePage() {
const [quizID, setQuizID] = useState('');
Expand Down Expand Up @@ -68,6 +70,9 @@ function HomePage() {
navigate('/create-quiz');
};

// Get the current page URL
const pageURL = window.location.href;

return (
<Container maxWidth="sm">
<Typography variant="h4" gutterBottom>
Expand Down Expand Up @@ -142,6 +147,21 @@ function HomePage() {
Create a New Quiz
</Button>
</Stack>

<Box sx={{ marginTop: 4, textAlign: 'center' }}>
<Typography variant="h6" gutterBottom>
Share this Page
</Typography>
<Box
sx={{
background: 'white',
display: 'inline-block',
padding: '16px',
}}
>
<QRCode value={pageURL} size={128} />
</Box>
</Box>
</Container>
);
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/QuizPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// QuizPage.js
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/ResultPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ResultPage.js
import React, { useEffect, useState, useRef } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import {
Expand Down
Loading