di usage in website
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user