Fix domain routing fallback and add dynamic favicons for student and admin portals
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 44s Details

This commit is contained in:
Sidney Gomes 2026-07-20 19:35:53 -03:00
parent 2045c33525
commit 4c71df1c9a
3 changed files with 25 additions and 4 deletions

4
public/favicon-admin.svg Normal file
View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="0" y="0" width="24" height="24" rx="4" fill="#E50914" stroke="none" />
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" fill="white" />
</svg>

After

Width:  |  Height:  |  Size: 313 B

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="0" y="0" width="24" height="24" rx="4" fill="#E50914" stroke="none" />
<polygon points="10 8 16 12 10 16 10 8" fill="white" stroke="white" />
</svg>

After

Width:  |  Height:  |  Size: 314 B

View File

@ -5,20 +5,33 @@ import AdminApp from './AdminApp.tsx';
export default function Root() { export default function Root() {
const [simulatedDomain] = useState<'student' | 'admin'>(() => { const [simulatedDomain] = useState<'student' | 'admin'>(() => {
// 1. Check hostname // 1. Check hostname
if (window.location.hostname.includes('admin')) { if (window.location.hostname.includes('admin-estudo') || window.location.hostname.startsWith('admin')) {
return 'admin'; return 'admin';
} }
// 2. Check path // 2. Check path
if (window.location.pathname.startsWith('/admin')) { if (window.location.pathname.startsWith('/admin')) {
return 'admin'; return 'admin';
} }
// 3. Fallback to localStorage
const saved = localStorage.getItem('microtecflix_simulated_domain'); // Always default to student if not explicitly admin
return saved === 'admin' ? 'admin' : 'student'; return 'student';
}); });
const isAdmin = simulatedDomain === 'admin'; const isAdmin = simulatedDomain === 'admin';
React.useEffect(() => {
// Dynamically update document title and favicon
document.title = isAdmin ? 'MicrotecFlix - Admin Portal' : 'MicrotecFlix - Plataforma de Estudos';
let link = document.querySelector("link[rel~='icon']") as HTMLLinkElement;
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.head.appendChild(link);
}
link.href = isAdmin ? '/favicon-admin.svg' : '/favicon-student.svg';
}, [isAdmin]);
return ( return (
<div className="relative min-h-screen"> <div className="relative min-h-screen">
{isAdmin ? <AdminApp /> : <App />} {isAdmin ? <AdminApp /> : <App />}