fix the booking and contract
Build & Push / Pipeline Tests (push) Failing after 1m31s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 55s
Test / API Unit Tests (push) Successful in 1m8s
Test / Homepage Unit Tests (push) Successful in 47s
Test / Carplace Unit Tests (push) Successful in 44s
Test / Admin Unit Tests (push) Successful in 43s
Test / Dashboard Unit Tests (push) Failing after 46s
Test / API Integration Tests (push) Successful in 1m7s

This commit is contained in:
root
2026-07-27 23:04:26 -04:00
parent 8046a1d447
commit 5649ab02c7
40 changed files with 1699 additions and 1066 deletions
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { toDashboardAppPath, toPublicDashboardPath } from './dashboardPaths'
import { buildHomepageSignInPath, toDashboardAppPath, toPublicDashboardPath } from './dashboardPaths'
describe('dashboard path normalization', () => {
it('collapses empty and root values to the app root', () => {
@@ -19,4 +19,10 @@ describe('dashboard path normalization', () => {
expect(toPublicDashboardPath('/dashboard/fleet')).toBe('/dashboard/fleet')
expect(toPublicDashboardPath('customers')).toBe('/dashboard/customers')
})
it('builds the canonical homepage sign-in URL with a dashboard return path', () => {
expect(buildHomepageSignInPath('/reservations')).toBe('/en/light/sign-in?redirect=%2Fdashboard%2Freservations')
expect(buildHomepageSignInPath('/dashboard/fleet', { locale: 'fr', theme: 'dark' })).toBe('/fr/dark/sign-in?redirect=%2Fdashboard%2Ffleet')
expect(buildHomepageSignInPath()).toBe('/en/light/sign-in')
})
})
+20
View File
@@ -1,4 +1,6 @@
const DASHBOARD_BASE_PATH = '/dashboard'
const DEFAULT_SIGN_IN_LOCALE = 'en'
const DEFAULT_SIGN_IN_THEME = 'light'
export function toDashboardAppPath(path?: string | null): string {
const value = (path ?? '').trim()
@@ -17,3 +19,21 @@ export function toPublicDashboardPath(path?: string | null): string {
const appPath = toDashboardAppPath(path)
return appPath === '/' ? DASHBOARD_BASE_PATH : `${DASHBOARD_BASE_PATH}${appPath}`
}
export function buildHomepageSignInPath(
currentPath?: string | null,
options: { locale?: string | null; theme?: string | null } = {},
): string {
const locale = options.locale === 'fr' || options.locale === 'ar' || options.locale === 'en'
? options.locale
: DEFAULT_SIGN_IN_LOCALE
const theme = options.theme === 'dark' || options.theme === 'light'
? options.theme
: DEFAULT_SIGN_IN_THEME
const params = new URLSearchParams()
if (currentPath) params.set('redirect', toPublicDashboardPath(currentPath))
const query = params.toString()
return `/${locale}/${theme}/sign-in${query ? `?${query}` : ''}`
}