From 22b7f4d7568dd02dcda0e013d58d89b950586a6c Mon Sep 17 00:00:00 2001 From: nvim Date: Mon, 2 Dec 2024 15:48:45 +0100 Subject: [PATCH] Add weekly popup --- src/App.tsx | 2 + src/components/WeeklyPopup/index.tsx | 55 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/components/WeeklyPopup/index.tsx diff --git a/src/App.tsx b/src/App.tsx index 4f8919e..8e3dcb7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,6 +10,7 @@ import logo from './assets/logo.png'; import { ToastContainer } from 'react-toastify'; import 'react-toastify/dist/ReactToastify.css'; import { ResultOutput } from './components/ResultOutput'; +import { WeeklyPopup } from './components/WeeklyPopup'; const App: React.FC = () => { const { url, handleUrlChange, handleFetch, @@ -19,6 +20,7 @@ const App: React.FC = () => { return (
{isLoading ? : null} +
Logo
diff --git a/src/components/WeeklyPopup/index.tsx b/src/components/WeeklyPopup/index.tsx new file mode 100644 index 0000000..66a9854 --- /dev/null +++ b/src/components/WeeklyPopup/index.tsx @@ -0,0 +1,55 @@ +import React, { useEffect, useState } from "react"; +import { Modal } from "../Modal"; + +export const WeeklyPopup: React.FC = () => { + const [isPopupVisible, setIsPopupVisible] = useState(false); + + useEffect(() => { + const now = new Date(); + const lastPopupDate = localStorage.getItem("lastPopupDate"); + + if (lastPopupDate) { + const lastDate = new Date(lastPopupDate); + const oneWeekLater = new Date(lastDate); + oneWeekLater.setDate(lastDate.getDay() + 7); + + if (now >= oneWeekLater) { + setIsPopupVisible(true); + } + } else { + setIsPopupVisible(true); + } + }, []); + + const handleClosePopup = () => { + setIsPopupVisible(false); + localStorage.setItem("lastPopupDate", new Date().toISOString()); + }; + + const ModalContent = () => { + return (
+

Hello

+

+ This project is open-source, so you can use it however you like. +

+

+ The inspiration for this project came from my work tasks, where I spent a lot of time retrieving data from FHIR implementation guides using FHIRPath expressions. +

+

+ The project has been developed (or will be developed) entirely in my free time. +

+

+ If you have any ideas, suggestions, or would like to contribute, please reach out via GitHub. +

+

+ You can find more information about me on this page: projkov.github.io +

+

+ Best regards,
+ Pavel Rozhkov +

+
) + } + + return } /> +}; \ No newline at end of file