feat: implement Story 2.3 — Worker-Scoped Dashboard

Scope stat cards and urgent declarations table to the authenticated
worker's own assignments. Add empty state when no declarations are
assigned, hide the "Assigné à" column for worker role, and expose
isWorker flag through DashboardController and dashboard types.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 17:31:23 +01:00
parent 4807376c49
commit 3baf456640
7 changed files with 818 additions and 161 deletions

View File

@@ -31,6 +31,7 @@ class DashboardController extends Controller
'alerts' => [],
'workspaceName' => null,
'roleLabel' => null,
'isWorker' => false,
'declarationsUrl' => null,
'clientsUrl' => null,
'viewAllAlertsUrl' => null,
@@ -105,31 +106,34 @@ class DashboardController extends Controller
->all();
$roleLabel = $this->roleLabels()[$workspaceUser->role->value] ?? $workspaceUser->role->value;
$isWorker = $workspaceUser->role->is(WorkspaceUserRole::Worker);
$assigneeParam = $isWorker ? ['assignee' => $user->id] : [];
$statCards = [
[
'label' => 'En retard',
'count' => $dashboardData['overdue'],
'status' => 'danger',
'href' => route('declarations.index', ['overdue' => 1]),
'href' => route('declarations.index', array_merge(['overdue' => 1], $assigneeParam)),
],
[
'label' => 'Cette semaine',
'count' => $dashboardData['dueThisWeek'],
'status' => 'warning',
'href' => route('declarations.index', ['due_this_week' => 1]),
'href' => route('declarations.index', array_merge(['due_this_week' => 1], $assigneeParam)),
],
[
'label' => 'En attente client',
'count' => $dashboardData['enAttenteClient'],
'status' => 'info',
'href' => route('declarations.index', ['status' => DeclarationStatus::EnAttenteClient]),
'href' => route('declarations.index', array_merge(['status' => DeclarationStatus::EnAttenteClient], $assigneeParam)),
],
[
'label' => 'En cours',
'count' => $dashboardData['enCours'],
'status' => 'success',
'href' => route('declarations.index', ['status' => DeclarationStatus::EnCours]),
'href' => route('declarations.index', array_merge(['status' => DeclarationStatus::EnCours], $assigneeParam)),
],
];
@@ -140,6 +144,7 @@ class DashboardController extends Controller
'alerts' => $dashboardData['alerts'],
'workspaceName' => $workspace->name,
'roleLabel' => $roleLabel,
'isWorker' => $isWorker,
'declarationsUrl' => route('declarations.index'),
'clientsUrl' => route('clients.index'),
'viewAllAlertsUrl' => route('declarations.index', ['filter' => 'alerts']),