]> git.localhorst.tv Git - alttp.git/commitdiff
restore page after login
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 25 Oct 2022 09:50:34 +0000 (11:50 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 25 Oct 2022 09:50:34 +0000 (11:50 +0200)
resources/js/components/common/Header.js
resources/js/components/pages/Front.js

index 96106a175491a142488ee8e2b903beec945b24da..6868477b54328a3078e16d8f10103f6ee446f92e 100644 (file)
@@ -52,7 +52,15 @@ const Header = ({ doLogout, user }) =>
                                                </Button>
                                        </>
                                :
-                                       <Button href="/login" variant="discord">
+                                       <Button
+                                               href="/login"
+                                               onClick={() => {
+                                                       if (location.pathname.length > 1) {
+                                                               localStorage.setItem('returnPath', location.pathname.substr(1));
+                                                       }
+                                               }}
+                                               variant="discord"
+                                       >
                                                <Icon.DISCORD />
                                                {' '}
                                                {i18n.t('button.login')}
index 26078696bac6262901ad4629d40ca5c480161450..73b9b23d8fb6f5e6482b1f17627647d76575dc65 100644 (file)
@@ -5,6 +5,14 @@ import { useNavigate } from 'react-router-dom';
 const Front = () => {
        const navigate = useNavigate();
 
+       React.useEffect(() => {
+               const returnPath = localStorage.getItem('returnPath');
+               if (returnPath) {
+                       localStorage.removeItem('returnPath');
+                       navigate(returnPath);
+               }
+       }, []);
+
        return <Container className="mt-5">
                <Row>
                        <Col md={6}>