feat:사이드바 메뉴 뱃지 기능 추가

- ViewServiceProvider에서 메뉴별 뱃지 데이터 전달
- 영업파트너 승인 대기 건수 뱃지 표시
- menu-item 컴포넌트에서 뱃지 렌더링 (빨간색 원형)
- 99개 초과 시 "99+" 표시

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
pro
2026-01-31 16:40:50 +09:00
parent 65234cab89
commit 13bb65a55b
2 changed files with 31 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Providers;
use App\Models\Tenants\Tenant;
use App\Services\Sales\SalesManagerService;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
@@ -31,5 +32,26 @@ public function boot(): void
$view->with('globalTenants', $globalTenants);
}
});
// 사이드바 메뉴 뱃지 데이터 (라우트명 => 건수)
View::composer('partials.sidebar', function ($view) {
$menuBadges = [];
if (auth()->check()) {
try {
$salesManagerService = app(SalesManagerService::class);
$approvalStats = $salesManagerService->getApprovalStats();
// 영업파트너 승인 대기 건수
if ($approvalStats['pending'] > 0) {
$menuBadges['sales.managers.approvals'] = $approvalStats['pending'];
}
} catch (\Exception $e) {
// 서비스 오류 시 무시
}
}
$view->with('menuBadges', $menuBadges);
});
}
}

View File

@@ -21,6 +21,9 @@
: 'text-gray-700 hover:bg-gray-100';
$target = $menu->is_external ? '_blank' : '_self';
// 메뉴 뱃지 확인 (라우트명 기준)
$badgeCount = isset($menuBadges) && $routeName ? ($menuBadges[$routeName] ?? 0) : 0;
@endphp
<li>
@@ -33,7 +36,12 @@ class="flex items-center gap-2 px-3 py-2 rounded-lg text-sm {{ $activeClass }}"
@if($menu->icon)
<x-sidebar.menu-icon :icon="$menu->icon" />
@endif
<span class="sidebar-text">{{ $menu->name }}</span>
<span class="sidebar-text flex-1">{{ $menu->name }}</span>
@if($badgeCount > 0)
<span class="sidebar-text inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 text-xs font-bold text-white bg-red-500 rounded-full">
{{ $badgeCount > 99 ? '99+' : $badgeCount }}
</span>
@endif
@if($menu->is_external)
<x-sidebar.menu-icon icon="external-link" class="w-3 h-3 opacity-50" />
@endif