Skip to content

Commit

Permalink
Redirect back to Instructions page after login from Map a Task
Browse files Browse the repository at this point in the history
  • Loading branch information
royallsilwallz committed Oct 8, 2024
1 parent 1447ba5 commit 111960f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/taskSelection/footer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { useNavigate, useLocation } from 'react-router-dom';
import Popup from 'reactjs-popup';
import { FormattedMessage } from 'react-intl';

Expand All @@ -24,6 +24,7 @@ const TaskSelectionFooter = ({
setSelectedTasks,
}) => {
const navigate = useNavigate();
const { pathname } = useLocation();
const token = useSelector((state) => state.auth.token);
const locale = useSelector((state) => state.preferences.locale);
const [editor, setEditor] = useState(defaultUserEditor);
Expand Down Expand Up @@ -225,7 +226,10 @@ const TaskSelectionFooter = ({
className="white bg-red fw5"
onClick={() => {
if (!token) {
navigate('/login');
navigate('/login', {
// for redirecting to the same page after login
state: { from: pathname },
});
} else {
lockTasks();
}
Expand Down

0 comments on commit 111960f

Please sign in to comment.