c97c16a752
- Implemented Settings page for changing user passwords with validation and feedback. - Created Setup page for initial admin account setup with form handling and navigation. - Added API service layer for handling requests related to proxy hosts, remote servers, and import functionality. - Introduced mock data for testing purposes and set up testing framework with vitest. - Configured Tailwind CSS for styling and Vite for development and build processes. - Added scripts for Dockerfile validation, Python syntax checking, and Sourcery integration. - Implemented release and coverage scripts for better CI/CD practices.
39 lines
906 B
TypeScript
39 lines
906 B
TypeScript
import { useEffect } from 'react';
|
|
import { useNavigate } from 'react-router-dom';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { getSetupStatus } from '../api/setup';
|
|
|
|
interface SetupGuardProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export const SetupGuard: React.FC<SetupGuardProps> = ({ children }) => {
|
|
const navigate = useNavigate();
|
|
|
|
const { data: status, isLoading } = useQuery({
|
|
queryKey: ['setupStatus'],
|
|
queryFn: getSetupStatus,
|
|
retry: false,
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (status?.setupRequired) {
|
|
navigate('/setup');
|
|
}
|
|
}, [status, navigate]);
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center bg-gray-100 dark:bg-gray-900">
|
|
<div className="text-blue-500">Loading...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (status?.setupRequired) {
|
|
return null; // Will redirect
|
|
}
|
|
|
|
return <>{children}</>;
|
|
};
|