From 7cf2918438ae8dd38f7f8609dc758b9d14018308 Mon Sep 17 00:00:00 2001 From: Charlie Zhang Date: Fri, 2 Aug 2024 15:41:35 -0400 Subject: [PATCH] Enable keeping downloading history: a) Add ModalManager and Signout Modal; b) Create separate modal reducers; c) Create independent history db; d) Fix all notification triggering process. --- src/renderer/src/App.jsx | 21 +++---- src/renderer/src/output.css | 42 +++++++++---- src/renderer/src/pages/DataDictionary.jsx | 11 +--- .../src/pages/DownloadHistory/index.jsx | 9 ++- src/renderer/src/pages/MainPage/index.jsx | 21 +++---- .../src/pages/Modals/ModalManager.jsx | 36 +++++++++++ .../NotificationModal.jsx} | 23 ++++---- .../src/pages/Modals/SignoutModal.jsx | 59 +++++++++++++++++++ src/renderer/src/reducers/authReducer.js | 44 ++++++++------ src/renderer/src/reducers/modalReducer.js | 22 +++++++ src/renderer/src/reducers/statusReducer.js | 26 ++++++-- src/renderer/src/service/db.js | 8 ++- src/renderer/src/store.js | 4 +- 13 files changed, 234 insertions(+), 92 deletions(-) create mode 100644 src/renderer/src/pages/Modals/ModalManager.jsx rename src/renderer/src/pages/{Modal.jsx => Modals/NotificationModal.jsx} (53%) create mode 100644 src/renderer/src/pages/Modals/SignoutModal.jsx create mode 100644 src/renderer/src/reducers/modalReducer.js diff --git a/src/renderer/src/App.jsx b/src/renderer/src/App.jsx index 6cf6f84..668a455 100644 --- a/src/renderer/src/App.jsx +++ b/src/renderer/src/App.jsx @@ -3,26 +3,27 @@ import { HashRouter as Router, Routes, Route, Link, Navigate } from 'react-route import { useSelector, useDispatch } from 'react-redux' import { initializeAuth, disconnect } from './reducers/authReducer' import MainPage from './pages/MainPage' -import NotificationModal from './pages/Modal' import Login from './pages/Login' import Footer from './pages/Footer' import About from './pages/About' import NavBar from './pages/NavBar' import HistoryPage from './pages/DownloadHistory' import DataDictionary from './pages/DataDictionary' -import { servicesDb, dictionaryDb } from './service/db' +import ModalManager from './pages/Modals/ModalManager' +import { servicesDb, dictionaryDb, queryDb } from './service/db' +import { openModal } from './reducers/modalReducer' const App = () => { const dispatch = useDispatch() const { dhis2Url, username, password, accessToken } = useSelector((state) => state.auth) - const { isLoading, errorMessage } = useSelector((state) => state.status) + const { isLoading, notification } = useSelector((state) => state.status) useEffect(() => { dispatch(initializeAuth()) }, [dispatch]) const handleDisconnect = async () => { - dispatch(disconnect()) + dispatch(openModal({ type: 'SIGN_OUT' })) } const PrivateRoute = ({ children }) => { @@ -49,7 +50,7 @@ const App = () => { path="/history" element={ - + } /> @@ -61,18 +62,12 @@ const App = () => { path="/home" element={ - + } /> - {(isLoading || errorMessage) && } +