feat: shift assignment workflow with claim, approve, reject, cancel, and bulk approve
Implements the complete ShiftAssignment lifecycle: - ShiftAssignmentStatus enum with allowed transitions - ShiftAssignmentService with claim/assign/approve/reject/cancel/bulkApprove - ShiftAssignmentController with event-scoped endpoints - ShiftAssignmentPolicy (organizer + volunteer self-cancel) - VolunteerAvailability model, controller, and sync endpoint - Refactored ShiftController to delegate to service layer - 31 workflow tests covering all paths and multi-tenancy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
34
api/app/Enums/ShiftAssignmentStatus.php
Normal file
34
api/app/Enums/ShiftAssignmentStatus.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ShiftAssignmentStatus: string
|
||||
{
|
||||
case PENDING_APPROVAL = 'pending_approval';
|
||||
case APPROVED = 'approved';
|
||||
case REJECTED = 'rejected';
|
||||
case CANCELLED = 'cancelled';
|
||||
case COMPLETED = 'completed';
|
||||
|
||||
/** @return list<self> */
|
||||
public function allowedTransitions(): array
|
||||
{
|
||||
return match ($this) {
|
||||
self::PENDING_APPROVAL => [self::APPROVED, self::REJECTED, self::CANCELLED],
|
||||
self::APPROVED => [self::CANCELLED, self::COMPLETED],
|
||||
self::REJECTED, self::CANCELLED, self::COMPLETED => [],
|
||||
};
|
||||
}
|
||||
|
||||
public function canTransitionTo(self $target): bool
|
||||
{
|
||||
return in_array($target, $this->allowedTransitions(), true);
|
||||
}
|
||||
|
||||
public function isTerminal(): bool
|
||||
{
|
||||
return $this->allowedTransitions() === [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user