Skip to content

Commit 3588e85

Browse files
authored
Merge pull request #73 from kunalkeshan/client-feat/feedback-modal
Feedback Modal Added
2 parents 4488a1b + a40da02 commit 3588e85

File tree

5 files changed

+137
-1
lines changed

5 files changed

+137
-1
lines changed

src/App.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Navbar from './components/layouts/Navbar';
1616
import Footer from './components/layouts/Footer';
1717
import CallToAction from './components/layouts/CallToAction';
1818
import ScrollToTop from './components/layouts/ScrollToTop';
19+
import FeedbackModal from './components/reuseable/FeedbackModal';
1920

2021
// Hooks
2122
import useGA from './hooks/useGA';
@@ -26,6 +27,7 @@ import WritingAnimation from './assets/lottie/writing.json';
2627

2728
function App() {
2829
const [show, setShow] = useState(false);
30+
const [openModal, setOpenModal] = useState(false);
2931

3032
useGA();
3133
usePageTracking();
@@ -74,6 +76,7 @@ function App() {
7476
</Container>
7577
<CallToAction />
7678
<ScrollToTop show={show} setShow={setShow} />
79+
<FeedbackModal open={openModal} setOpen={setOpenModal} />
7780
<Footer />
7881
</Main>
7982
);

src/components/layouts/CallToAction.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { SpeedDial, SpeedDialAction, styled } from '@mui/material'
1212
import ShareIcon from '@mui/icons-material/Share';
1313
import WhatsAppIcon from '@mui/icons-material/WhatsApp';
1414
import TwitterIcon from '@mui/icons-material/Twitter';
15+
import FeedbackIcon from '@mui/icons-material/Feedback';
1516

1617
// Hooks
1718
import useGA from '../../hooks/useGA';
@@ -30,7 +31,12 @@ const CallToAction = () => {
3031
name: 'Share with Twitter',
3132
url: `http://twitter.com/share?text=Check out this website to get the best ECE Notes available out there! @_kunalkeshan_&url=${window.location.protocol}//${window.location.host}?utm_source=twitter.com&utm_medium=social&hashtags=srmist,ece,btech,kunalkeshan`,
3233
icon: <TwitterIcon sx={{ '&:hover': { color: '#1DA1F2 !important' } }} />
33-
}
34+
},
35+
{
36+
name: 'Have some Feedback?',
37+
url: config.GOOGLE_FORM_FEEDBACK_URL,
38+
icon: <FeedbackIcon sx={{ '&:hover': { color: `${config.APP_COLORS.main} !important` } }} />
39+
},
3440
];
3541

3642
const handleClick = (url) => () => {

src/components/layouts/Footer.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ const Footer = () => {
4949
name: 'Drive',
5050
link: 'https://drive.google.com/drive/u/7/folders/17bng9aIkZ3FaULebbgEGpdCsB225dr_K',
5151
},
52+
{
53+
name: 'Give Feedback',
54+
link: config.GOOGLE_FORM_FEEDBACK_URL,
55+
}
5256
];
5357

5458
const handleNavigate = ({ link = null, nav = null }) => {
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/**
2+
* Feedback Modal
3+
*/
4+
5+
// Dependencies
6+
import React, { useEffect, useState } from 'react';
7+
import config from '../../config';
8+
9+
import {
10+
Dialog,
11+
DialogTitle,
12+
styled,
13+
Container,
14+
Typography,
15+
Link,
16+
DialogActions,
17+
Button,
18+
} from '@mui/material';
19+
20+
21+
22+
const FeedbackModal = ({ open, setOpen }) => {
23+
const TWO_WEEKS_MS = 1.21e9;
24+
const THIRTY_MS = 1000 * 30;
25+
const [, setFormStatus] = useState({
26+
lastShown: null,
27+
});
28+
29+
const onClose = () => {
30+
setOpen(false);
31+
};
32+
33+
useEffect(() => {
34+
const handleShowForm = () => {
35+
setTimeout(() => {
36+
setOpen(true);
37+
setFormStatus((prev) => {
38+
const newStatus = {
39+
...prev,
40+
lastShown: Date.now(),
41+
};
42+
localStorage.setItem(
43+
'formStatus',
44+
JSON.stringify(newStatus)
45+
);
46+
return newStatus;
47+
});
48+
}, THIRTY_MS);
49+
};
50+
51+
const handleFormStatus = () => {
52+
let localFormStatus = localStorage.getItem('formStatus');
53+
if (localFormStatus) {
54+
localFormStatus = JSON.parse(localFormStatus);
55+
setFormStatus(localFormStatus);
56+
if (localFormStatus.lastShown !== null) {
57+
const now = Date.now();
58+
if (now - localFormStatus.lastShown > TWO_WEEKS_MS)
59+
handleShowForm();
60+
} else handleShowForm();
61+
} else handleShowForm();
62+
};
63+
handleFormStatus();
64+
}, [THIRTY_MS, setOpen]);
65+
66+
return (
67+
<Dialog
68+
open={open}
69+
onClose={onClose}
70+
sx={{
71+
overflowX: 'hidden',
72+
'.MuiPaper-root': {
73+
width: 'fit-content',
74+
maxWidth: 'none',
75+
},
76+
}}
77+
>
78+
<Container>
79+
<DialogTitle>Feedback Form</DialogTitle>
80+
<Typography mx={3} mb={2}>
81+
Unable to view the form, use{' '}
82+
<Link
83+
href={config.GOOGLE_FORM_FEEDBACK_URL}
84+
target='_blank'
85+
>
86+
{' '}
87+
this link instead
88+
</Link>
89+
.
90+
</Typography>
91+
<FormIframe
92+
src={`${config.GOOGLE_FORM_FEEDBACK_URL}&embedded=true`}
93+
frameBorder='0'
94+
title='Shiryoku Feedback Form'
95+
>
96+
Loading…
97+
</FormIframe>
98+
<DialogActions>
99+
<CloseButton variant='text' color='error' onClick={onClose}>
100+
Close
101+
</CloseButton>
102+
</DialogActions>
103+
</Container>
104+
</Dialog>
105+
);
106+
};
107+
108+
const FormIframe = styled('iframe')({
109+
width: '640px',
110+
height: '520px',
111+
overflowX: 'hidden',
112+
'@media(max-width: 700px)': {
113+
width: '520px',
114+
},
115+
'@media(max-width: 440px)': {
116+
width: '280px',
117+
},
118+
});
119+
120+
const CloseButton = styled(Button)({});
121+
122+
export default FeedbackModal;

src/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const config = {
4949
github: 'https://github.com/kunalkeshan',
5050
youtube: 'https://www.youtube.com/channel/UCwVRztzBdqgB_Y9hkMX3lZA',
5151
},
52+
GOOGLE_FORM_FEEDBACK_URL: 'https://docs.google.com/forms/d/e/1FAIpQLSfNQDOQkEKPubOBRIhselYTjCv82qv7qTyPh6exFvkT3sumhw/viewform?usp=pp_url&entry.34189569=Notes+Initiative',
5253
};
5354

5455
export default config;

0 commit comments

Comments
 (0)