diff --git a/apps/dashboard/src/components/layout/Sidebar.boundary.test.ts b/apps/dashboard/src/components/layout/Sidebar.boundary.test.ts index 11915c1..d410df8 100644 --- a/apps/dashboard/src/components/layout/Sidebar.boundary.test.ts +++ b/apps/dashboard/src/components/layout/Sidebar.boundary.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest' -import { APPROVED_BASELINE_MENU_KEYS, hasRenderableMenuItems, shouldUseGeneratedMenu } from './Sidebar' +import { APPROVED_BASELINE_MENU_KEYS, getEmployeeLogoutRedirectUrl, hasRenderableMenuItems, shouldUseGeneratedMenu } from './Sidebar' describe('Sidebar menu rendering helpers', () => { it('keeps the safe fallback menu to the approved seven baseline items in order', () => { @@ -14,6 +14,11 @@ describe('Sidebar menu rendering helpers', () => { ]) }) + it('redirects employee logout to the public website instead of Carplace', () => { + expect(getEmployeeLogoutRedirectUrl()).toBe('http://localhost:3000') + expect(getEmployeeLogoutRedirectUrl()).not.toContain('/carplace') + }) + it('treats an empty employee menu as non-renderable so fallback navigation remains available', () => { expect(hasRenderableMenuItems(null)).toBe(false) expect(hasRenderableMenuItems([])).toBe(false) diff --git a/apps/dashboard/src/components/layout/Sidebar.tsx b/apps/dashboard/src/components/layout/Sidebar.tsx index 1efcf5f..e282c3e 100644 --- a/apps/dashboard/src/components/layout/Sidebar.tsx +++ b/apps/dashboard/src/components/layout/Sidebar.tsx @@ -24,7 +24,7 @@ import { AlertTriangle, } from 'lucide-react' import { DashboardLanguageSwitcher, DashboardThemeSwitcher, useDashboardI18n } from '@/components/I18nProvider' -import { carplaceUrl } from '@/lib/urls' +import { carplaceUrl, websiteUrl } from '@/lib/urls' import { EMPLOYEE_PROFILE_KEY, apiFetch } from '@/lib/api' import { toDashboardAppPath } from '@/lib/dashboardPaths' import { SHARED_LANGUAGE_KEY, readCurrentUserScopedPreference } from '@/lib/preferences' @@ -148,6 +148,10 @@ export function shouldUseGeneratedMenu( return hasRenderableMenuItems(items) } +export function getEmployeeLogoutRedirectUrl() { + return websiteUrl +} + function notifyParent(message: Record) { if (typeof window === 'undefined' || window.parent === window) return window.parent.postMessage(message, '*') @@ -395,7 +399,7 @@ export default function Sidebar() { void fetch('/dashboard/api/v1/auth/employee/logout', { method: 'POST', credentials: 'include' }) window.dispatchEvent(new CustomEvent('rentaldrivego:auth-changed')) notifyParent({ type: 'rentaldrivego:employee-logout' }) - window.location.href = carplaceUrl + window.location.href = getEmployeeLogoutRedirectUrl() } return (