wip
This commit is contained in:
@@ -16,5 +16,25 @@ export function useEffectiveDriverId(): string {
|
||||
}
|
||||
| undefined;
|
||||
|
||||
return user?.primaryDriverId ?? 'driver-1';
|
||||
// In alpha mode, if the user has no bound driver yet, fall back to the
|
||||
// first seeded driver from the in-memory repository instead of a hardcoded ID.
|
||||
if (user?.primaryDriverId) {
|
||||
return user.primaryDriverId;
|
||||
}
|
||||
|
||||
try {
|
||||
// Lazy-load to avoid importing DI facade at module evaluation time
|
||||
const { getDriverRepository } = require('./di-container') as typeof import('./di-container');
|
||||
const repo = getDriverRepository();
|
||||
// In-memory repository is synchronous for findAll in the demo implementation
|
||||
const allDrivers = repo.findAllSync?.() as Array<{ id: string }> | undefined;
|
||||
if (allDrivers && allDrivers.length > 0) {
|
||||
return allDrivers[0].id;
|
||||
}
|
||||
} catch {
|
||||
// Ignore and fall back to legacy default below
|
||||
}
|
||||
|
||||
// Legacy fallback: preserved only as a last resort for demo
|
||||
return '';
|
||||
}
|
||||
Reference in New Issue
Block a user