Refactor Site Builder Integration and Update Docker Configuration

- Merged the site builder functionality into the main app, enhancing the SiteBuilderWizard component with new steps and improved UI.
- Updated the Docker Compose configuration by removing the separate site builder service and integrating its functionality into the igny8_sites service.
- Enhanced Vite configuration to support code-splitting for builder routes, optimizing loading times.
- Updated package dependencies to include new libraries for state management and form handling.
This commit is contained in:
IGNY8 VPS (Salman)
2025-11-18 10:35:30 +00:00
parent 8508af37c7
commit 3ea519483d
19 changed files with 1637 additions and 91 deletions

View File

@@ -0,0 +1,44 @@
import { useEffect, useState } from 'react';
import { Navigate, useLocation } from 'react-router-dom';
/**
* ProtectedRoute component that checks for authentication token.
* Redirects to login if not authenticated.
*/
interface ProtectedRouteProps {
children: React.ReactNode;
}
export default function ProtectedRoute({ children }: ProtectedRouteProps) {
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
const location = useLocation();
useEffect(() => {
// Check for JWT token in localStorage
const token = localStorage.getItem('auth-storage');
if (token) {
try {
const authData = JSON.parse(token);
setIsAuthenticated(!!authData?.state?.token);
} catch {
setIsAuthenticated(false);
}
} else {
setIsAuthenticated(false);
}
}, []);
if (isAuthenticated === null) {
// Still checking authentication
return <div>Checking authentication...</div>;
}
if (!isAuthenticated) {
// Redirect to login (or main app login page)
// In production, this might redirect to app.igny8.com/login
return <Navigate to="/login" state={{ from: location }} replace />;
}
return <>{children}</>;
}