feat: Integrate SetupCheck component for improved setup validation in routing

This commit is contained in:
CaIon
2025-04-08 17:31:46 +08:00
parent aa34c3035a
commit 5813ca780f
3 changed files with 23 additions and 7 deletions

View File

@@ -0,0 +1,18 @@
import React, { useContext, useEffect } from 'react';
import { Navigate, useLocation } from 'react-router-dom';
import { StatusContext } from '../context/Status';
const SetupCheck = ({ children }) => {
const [statusState] = useContext(StatusContext);
const location = useLocation();
useEffect(() => {
if (statusState?.status?.setup === false && location.pathname !== '/setup') {
window.location.href = '/setup';
}
}, [statusState?.status?.setup, location.pathname]);
return children;
};
export default SetupCheck;