diff options
author | Galen Guyer <galen@galenguyer.com> | 2022-08-31 19:07:34 -0400 |
---|---|---|
committer | Galen Guyer <galen@galenguyer.com> | 2022-08-31 19:07:34 -0400 |
commit | 3e5d8a822c1b47b9730574973711b81ce9192ab5 (patch) | |
tree | d64d7895b78f54a391fe90b01ae26f25eb159f48 | |
parent | fb5d9a79fea2510fc23881b08aa8776874a3a6c6 (diff) |
Logo takes you to zones page if logged in
-rw-r--r-- | src/App.js | 4 | ||||
-rw-r--r-- | src/hooks/useErrorModal.js | 47 |
2 files changed, 50 insertions, 1 deletions
@@ -54,11 +54,13 @@ function ButtonRow() { ) } function App() { + let auth = useAuth() + return ( <div className="App"> <BrowserRouter> <header> - <Link to="/"> + <Link to={auth.isAuthenticated() ? "/zones" : "/"}> <h1> HOSTS<b>dot</b>TXT </h1> diff --git a/src/hooks/useErrorModal.js b/src/hooks/useErrorModal.js new file mode 100644 index 0000000..9117149 --- /dev/null +++ b/src/hooks/useErrorModal.js @@ -0,0 +1,47 @@ +import React from 'react' +import { isExpired } from 'react-jwt' +import { Navigate, useLocation } from 'react-router-dom' + +let ErrorModalContext = React.createContext() + +export function ErrorModalProvider({ children }) { + let [showModal, setShowModal] = React.useState(false) + + let show = (message) => { + setShowModal(true); + } + let hide = () => { + setShowModal(false); + } + + let value = { show, hide }; + + return <ErrorModalContext.Provider value={value}>{children} {showModal ? <ErrorModal /> : null }</ErrorModalContext.Provider> +} + +export function useErrorModal() { + return React.useContext(ErrorModalContext) +} + +const modalStyle = { + content: { + top: '50%', + left: '50%', + right: 'auto', + bottom: 'auto', + marginRight: '-50%', + transform: 'translate(-50%, -50%)', + }, +} + +function ErrorModal({ content }) { + return ( + <Modal + isOpen={showModal} + onRequestClose={() => setShowModal(false)} + style={modalStyle} + > + LIGMAAAAAAAA + </Modal> + ) +} |