-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathChangelogModal.tsx
41 lines (32 loc) · 1.36 KB
/
ChangelogModal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { useEffect, useState } from 'react';
import './ChangelogModal.scss';
import Modal from 'react-bootstrap/Modal';
const DESCRIPTION = 'You can now view recently added features to the PeterPortal website, listed in this modal.';
const IMAGE_URL =
'https://media.tenor.com/ufm_0t3ACEAAAAAM/ginger-cat-ginger-cat-eating-then-staring-at-the-camera.gif';
const LAST_UPDATED = '02/27/2024';
const ChangelogModal = () => {
const [showModal, setShowModal] = useState(false);
useEffect(() => {
// display the changelog modal if it is the user's first time seeing it (tracked in local storage)
const lastSeen = localStorage.getItem('changelogSeen');
if (lastSeen !== LAST_UPDATED) {
setShowModal(true);
// mark as seen so it is not displayed after seeing it once
localStorage.setItem('changelogSeen', LAST_UPDATED);
}
}, []);
const closeModal = () => {
setShowModal(false);
};
return (
<Modal className="changelog-modal" show={showModal} centered onHide={closeModal}>
<Modal.Header closeButton>
<h2>What's New - {new Date(LAST_UPDATED).toLocaleString('default', { month: 'long', year: 'numeric' })}</h2>
</Modal.Header>
<p className="modal-body">{DESCRIPTION}</p>
<img className="modal-img" src={IMAGE_URL} alt="Screenshot or gif of new changes" />
</Modal>
);
};
export default ChangelogModal;