di usage in website

This commit is contained in:
2026-01-06 19:36:03 +01:00
parent 589b55a87e
commit e589c30bf8
191 changed files with 6367 additions and 4253 deletions

View File

@@ -1,26 +1,10 @@
'use client';
import { useAuth } from '@/lib/auth/AuthContext';
import { useCurrentDriver } from './driver/useCurrentDriver';
/**
* 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).
* Hook to get the current driver ID from the user's session.
* Returns the driver ID string or undefined if not available.
*/
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 '';
export function useEffectiveDriverId(): string | undefined {
const { data: currentDriver } = useCurrentDriver();
return currentDriver?.id;
}