fix(capacity): Fix three defects - caching, save, filters
1. Slow Team Member Dropdown - Fixed - Added cached team members store with 5-minute TTL - Dropdown now loads instantly on subsequent visits 2. Error Preventing Capacity Save - Fixed - Added saveAvailability API endpoint - Added backend service method to persist availability overrides - Added proper error handling and success feedback - Cache invalidation on save 3. Filters Not Working - Fixed - Fixed PTOManager to use shared selectedMemberId - Filters now react to team member selection Test Results: - Backend: 76 passed ✅ - Frontend Unit: 10 passed ✅ - E2E: 130 passed, 24 skipped ✅ Refs: openspec/changes/headroom-foundation
This commit is contained in:
@@ -273,6 +273,21 @@ class CapacityService
|
||||
->mapWithKeys(fn (TeamMemberAvailability $entry) => [$entry->date->toDateString() => (float) $entry->availability]);
|
||||
}
|
||||
|
||||
public function upsertTeamMemberAvailability(string $teamMemberId, string $date, float $availability): TeamMemberAvailability
|
||||
{
|
||||
$entry = TeamMemberAvailability::updateOrCreate(
|
||||
['team_member_id' => $teamMemberId, 'date' => $date],
|
||||
['availability' => $availability]
|
||||
);
|
||||
|
||||
$month = Carbon::createFromFormat('Y-m-d', $date)->format('Y-m');
|
||||
|
||||
$this->forgetCapacityCacheForTeamMember($teamMemberId, [$month]);
|
||||
$this->forgetCapacityCacheForMonth($month);
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CarbonPeriod for the given month.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user