Skip to content

Commit

Permalink
Resolve sonar qude issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mjatin-dev committed Dec 27, 2024
1 parent 0931dc6 commit 903e6a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 0 additions & 4 deletions admin-ui/app/routes/Pages/ByeBye.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ import { uuidv4 } from "Utils/Util";
import { EmptyLayout, Label } from "Components";
import { logoutUser } from "Redux/features/logoutSlice";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router";
import { Navigate } from 'react-router-dom';
import { setAuthState } from "../../redux/features/authSlice";

function ByeBye() {
const config = useSelector((state) => state.authReducer.config);
const { userinfo } = useSelector((state) => state.authReducer);
const navigate = useNavigate();

const dispatch = useDispatch();
const { t } = useTranslation();
Expand Down
7 changes: 6 additions & 1 deletion admin-ui/app/routes/Pages/ProtectRoutes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from "react";
import PropTypes from "prop-types";
import { Navigate } from "react-router-dom";
import { useSelector } from "react-redux";

const ProtectedRoute = ({ children }) => {
const isAuthenticated = useSelector(
(state) => state.authReducer.isAuthenticated
);

if (!isAuthenticated) {
// Redirect to login if the user is not authenticated
return <Navigate to="/" replace />;
Expand All @@ -16,4 +17,8 @@ const ProtectedRoute = ({ children }) => {
return children;
};

ProtectedRoute.propTypes = {
children: PropTypes.node.isRequired, // Enforce that children must be a React node
};

export default ProtectedRoute;

0 comments on commit 903e6a2

Please sign in to comment.