From 4c71df1c9adeb88bf7dee2a983233a4e9dcf589b Mon Sep 17 00:00:00 2001 From: Sidney Gomes Date: Mon, 20 Jul 2026 19:35:53 -0300 Subject: [PATCH] Fix domain routing fallback and add dynamic favicons for student and admin portals --- public/favicon-admin.svg | 4 ++++ public/favicon-student.svg | 4 ++++ src/Root.tsx | 21 +++++++++++++++++---- 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 public/favicon-admin.svg create mode 100644 public/favicon-student.svg diff --git a/public/favicon-admin.svg b/public/favicon-admin.svg new file mode 100644 index 0000000..1343a88 --- /dev/null +++ b/public/favicon-admin.svg @@ -0,0 +1,4 @@ + + + + diff --git a/public/favicon-student.svg b/public/favicon-student.svg new file mode 100644 index 0000000..9974973 --- /dev/null +++ b/public/favicon-student.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/Root.tsx b/src/Root.tsx index c001efb..7bffd1c 100644 --- a/src/Root.tsx +++ b/src/Root.tsx @@ -5,20 +5,33 @@ import AdminApp from './AdminApp.tsx'; export default function Root() { const [simulatedDomain] = useState<'student' | 'admin'>(() => { // 1. Check hostname - if (window.location.hostname.includes('admin')) { + if (window.location.hostname.includes('admin-estudo') || window.location.hostname.startsWith('admin')) { return 'admin'; } // 2. Check path if (window.location.pathname.startsWith('/admin')) { return 'admin'; } - // 3. Fallback to localStorage - const saved = localStorage.getItem('microtecflix_simulated_domain'); - return saved === 'admin' ? 'admin' : 'student'; + + // Always default to student if not explicitly admin + return 'student'; }); 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 (
{isAdmin ? : }