JSFiddle - React, Tailwind, and code Playground
HTML
<?php
$username = $loginRedirect = $hideMenu = $isCompany = $inboxCount = $appCount = null;
$active = $this->active;
if($this->identity) {
$username = $this->identity->screenName;
$hideMenu = $this->hideMenu;
$isCompany = ('company' === $this->identity->role);
// TODO: move those to identity row and cache them:
$inboxCount = Service_Registry::getService('Messages')->countUnreadMessages($this->identity->id);
$appCount = count(Service_Registry::getService('Appointments')->findAppointmentsToBeConfirmed($this->identity->id));
}
elseif($this->loginRedirect) {
$loginRedirect = $this->loginRedirect;
}
$loginUrl = '/users/login' . ($loginRedirect ? '?redirect=' . urlencode($loginRedirect) : '');
if($username && !$isCompany) {
$inboxCountText = $inboxCount ? " ($inboxCount)" : '';
$appCountText = $appCount ? " ($appCount)" : '';
$items = array(
// 'home' => array('/', 'Home'),
'dashboard' => array('/dashboard', 'Dashboard'),
'requests' => array('/requests', 'Open Consults'),
'inbox' => array('/messages', 'Inbox' . $inboxCountText),
'calendar' => array('/calendar', 'Calendar' . $appCountText),
'pov' => array('/blogs/index', 'Write an Insight'),
// 'payments' => array('/payments/index', 'Payments'),
// 'your_blog' => array('/research/wp-admin/', 'Your Blog'),
);
}
elseif ($isCompany) {
$items = array(
'home' => array('/', 'Home'),
'dashboard' => array('/company/dashboard', 'Group Admin'),
'profile' => array('/company/viewprofile', 'Company Profile'),
'inbox' => array('/messages', 'Inbox'),
'payments' => array('/payments', 'Company Payments'),
/** 'support' => array('/research/support/', 'Support'),*/
);
}
else {
$items = array(
'home' => array('/', 'Home'),
/** 'why' => array('/research/advisors/', 'Why Join'),*/
'faq' => array('/research/faq/', ...