feat(team-member): Complete Team Member Management capability

Implement full CRUD operations for team members with TDD approach:

Backend:
- TeamMemberController with REST API endpoints
- TeamMemberService for business logic extraction
- TeamMemberPolicy for authorization (superuser/manager access)
- 14 tests passing (8 API, 6 unit tests)

Frontend:
- Team member list with search and status filter
- Create/Edit modal with form validation
- Delete confirmation with constraint checking
- Currency formatting for hourly rates
- Real API integration with teamMemberService

Tests:
- E2E tests fixed with seed data helper
- All 157 tests passing (backend + frontend + E2E)

Closes #22
This commit is contained in:
2026-02-18 22:01:57 -05:00
parent 249e0ade8e
commit 3173d4250c
18 changed files with 1588 additions and 1100 deletions

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Policies;
use App\Models\TeamMember;
use App\Models\User;
class TeamMemberPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
// All authenticated users can view team members
return true;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, TeamMember $teamMember): bool
{
// All authenticated users can view individual team members
return true;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
// Only superusers and managers can create team members
return in_array($user->role, ['superuser', 'manager']);
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, TeamMember $teamMember): bool
{
// Only superusers and managers can update team members
return in_array($user->role, ['superuser', 'manager']);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, TeamMember $teamMember): bool
{
// Only superusers and managers can delete team members
return in_array($user->role, ['superuser', 'manager']);
}
/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, TeamMember $teamMember): bool
{
// Only superusers and managers can restore team members
return in_array($user->role, ['superuser', 'manager']);
}
/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, TeamMember $teamMember): bool
{
// Only superusers can force delete team members
return $user->role === 'superuser';
}
}