Terms of Service added

This commit is contained in:
Luke Berndt
2024-06-29 07:57:35 -04:00
parent 4fde3f062d
commit ca342cd9f2
8 changed files with 172 additions and 83 deletions

View File

@@ -2,15 +2,17 @@
import React, { useEffect } from "react";
import { useSelector, useDispatch } from 'react-redux'
import { authenticateUser } from "../features/user/userSlice";
import { useNavigate } from 'react-router-dom';
import { useNavigate, useLocation } from 'react-router-dom';
/**
* Higher-order component (HOC) to wrap restricted pages
*/
const Restricted = ({ children }) => {
const { authenticated, hasAuthenticated } = useSelector((state) => state.user);
const { authenticated, hasAuthenticated,terms } = useSelector((state) => state.user);
const dispatch = useDispatch();
const navigate = useNavigate();
const location = useLocation();
const { hash, pathname, search } = location;
useEffect(() => {
dispatch(authenticateUser({}));
@@ -18,6 +20,9 @@ const Restricted = ({ children }) => {
if (hasAuthenticated) {
if (authenticated) {
if ((pathname != "/terms") && (terms != 1.1)) {
navigate("/terms")
}
return children;
}
else {