This commit is contained in:
2025-12-18 14:30:19 +01:00
parent bf1f09c774
commit b476bb7e99
29 changed files with 273 additions and 307 deletions

View File

@@ -0,0 +1,26 @@
'use client';
import { useAuth } from '@/lib/auth/AuthContext';
/**
* Returns the effective driver ID for the current session.
*
* Prefers the authenticated user's primaryDriverId when available,
* otherwise returns an empty string (user must log in to have a driver).
*/
export function useEffectiveDriverId(): string {
const { session } = useAuth();
const user = session?.user as
| {
primaryDriverId?: string | null;
}
| undefined;
// Return the user's primary driver ID if available
if (user?.primaryDriverId) {
return user.primaryDriverId;
}
// No driver ID available - user needs to log in or complete onboarding
return '';
}