fix: display correct resolved user department in sidebar profile card

This commit is contained in:
antv
2026-07-08 15:48:05 +07:00
parent 5e6ce46e00
commit bdd58e0d17
+12 -1
View File
@@ -58,12 +58,23 @@
: (Auth::check() && Auth::user()->name
? 'https://api.dicebear.com/7.x/notionists/svg?seed=' . urlencode(Auth::user()->name) . '&backgroundColor=e2e8f0'
: asset('images/avatar.png'));
$deptName = 'Product Team';
if (Auth::check()) {
$deptVal = Auth::user()->departments;
if (is_numeric($deptVal)) {
$idx = ((int)$deptVal) - 1;
$deptName = config('constants.DEPARTMENTS')[$idx] ?? 'Team';
} else {
$deptName = $deptVal ?? 'Team';
}
}
@endphp
<img src="{{ $avatarUrl }}" alt="Avatar" class="w-full h-full object-cover">
</div>
<div class="flex flex-col">
<span class="text-[14px] font-bold text-[#1e293b] leading-tight truncate max-w-[130px]">{{ Auth::check() ? (Auth::user()->name ?? 'Nguyễn Minh Anh') : 'Nguyễn Minh Anh' }}</span>
<span class="text-[12px] text-gray-500 font-medium">{{ Auth::check() ? (Auth::user()->role == config('constants.ROLE_ADMIN') ? 'Administrator' : 'Product Team') : 'Product Team' }}</span>
<span class="text-[12px] text-gray-500 font-medium truncate max-w-[130px]" title="{{ $deptName }}">{{ $deptName }}</span>
</div>
</div>
<svg class="w-4 h-4 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7" /></svg>