@props(['title' => null])
@php
// Every role has a personal space (their own plan). An expert also has the expert area, an administrator the administration:
// inside the expert area the bar is the expert's, everywhere else it is the personal one, with a switch to the role's own area.
$role = auth()->user()?->role;
$isExpert = $role === App\Enums\Role::Expert && request()->routeIs('expert.*');
$switch = match ($role) {
App\Enums\Role::Expert => ['ui.nav_switch_expert', route('expert.home')],
App\Enums\Role::Admin => ['ui.nav_switch_admin', url('/admin')],
default => null,
};
$unread = auth()->user()?->unreadNotifications()->count() ?? 0;
$planChip = ($u = auth()->user()) && ! $isExpert && $u->workspaces()->count() > 1 ? app(App\Services\Plan\CurrentCycle::class)->get()?->workspace?->name : null;
$icons = [
'home' => '',
'plan' => '',
'chat' => '',
'pilot' => '',
'bell' => '',
'user' => '',
'admin' => '',
];
$onPilot = request()->routeIs(...App\Services\Plan\PilotageTools::ROUTES);
// [route, label, is the current screen in this area?, icon]
$mainNav = $isExpert
? [['expert.home', 'expert.title', true, 'chat'], ['dashboard', 'ui.nav_my_space', false, 'home'], ['account', 'ui.nav_account', false, 'user']]
: [
['dashboard', 'ui.nav_home', request()->routeIs('dashboard'), 'home'],
['plan.home', 'plan.nav_plan', request()->routeIs('plan.*') && ! $onPilot, 'plan'],
['plan.dashboard', 'ui.nav_pilot', $onPilot || request()->routeIs('consultations'), 'pilot'],
['reminders', 'ui.nav_reminders', request()->routeIs('reminders'), 'bell'],
['account', 'ui.nav_account', request()->routeIs('account'), 'user'],
];
@endphp
@if ($planChip)
{{ $planChip }}
@endif
@if ($switch && ! $isExpert)
{{ __($switch[0]) }}
@endif
{{-- Computer: the name, however long, is a menu (the account, signing out). Phone: the account is in the bottom bar. --}}