|
4 | 4 |
|
5 | 5 | use App\Actions\Licenses\DeleteLicense;
|
6 | 6 | use App\Actions\Licenses\SuspendLicense;
|
| 7 | +use App\Actions\Licenses\UnsuspendLicense; |
7 | 8 | use App\Filament\Resources\LicenseResource;
|
8 | 9 | use App\Jobs\UpsertLicenseFromAnystackLicense;
|
9 | 10 | use App\Models\License;
|
@@ -57,19 +58,52 @@ protected function getHeaderActions(): array
|
57 | 58 | Actions\Action::make('suspend')
|
58 | 59 | ->label('Suspend')
|
59 | 60 | ->icon('heroicon-o-archive-box-x-mark')
|
60 |
| - ->color('danger') |
| 61 | + ->color('warning') |
61 | 62 | ->requiresConfirmation()
|
62 | 63 | ->modalHeading('Suspend')
|
63 | 64 | ->modalDescription('Are you sure you want to suspend this license?')
|
64 |
| - ->modalSubmitActionLabel('Suspend license') |
| 65 | + ->modalSubmitActionLabel('Suspend') |
65 | 66 | ->visible(fn () => ! $this->record->is_suspended)
|
66 | 67 | ->action(function () {
|
67 |
| - app(SuspendLicense::class)->handle($this->record); |
| 68 | + try { |
| 69 | + app(SuspendLicense::class)->handle($this->record); |
68 | 70 |
|
69 |
| - Notification::make() |
70 |
| - ->title('License suspended successfully') |
71 |
| - ->success() |
72 |
| - ->send(); |
| 71 | + Notification::make() |
| 72 | + ->title('License suspended successfully') |
| 73 | + ->success() |
| 74 | + ->send(); |
| 75 | + } catch (\Exception $e) { |
| 76 | + Notification::make() |
| 77 | + ->title('Error suspending license') |
| 78 | + ->body('Failed to suspend license: '.$e->getMessage()) |
| 79 | + ->danger() |
| 80 | + ->send(); |
| 81 | + } |
| 82 | + }), |
| 83 | + Actions\Action::make('unsuspend') |
| 84 | + ->label('Unsuspend') |
| 85 | + ->icon('heroicon-o-power') |
| 86 | + ->color('warning') |
| 87 | + ->requiresConfirmation() |
| 88 | + ->modalHeading('Unsuspend') |
| 89 | + ->modalDescription('Are you sure you want to remove the suspension for this license?') |
| 90 | + ->modalSubmitActionLabel('Unsuspend') |
| 91 | + ->visible(fn () => $this->record->is_suspended) |
| 92 | + ->action(function () { |
| 93 | + try { |
| 94 | + app(UnsuspendLicense::class)->handle($this->record); |
| 95 | + |
| 96 | + Notification::make() |
| 97 | + ->title('License unsuspended successfully') |
| 98 | + ->success() |
| 99 | + ->send(); |
| 100 | + } catch (\Exception $e) { |
| 101 | + Notification::make() |
| 102 | + ->title('Error unsuspending license') |
| 103 | + ->body('Failed to unsuspend license: '.$e->getMessage()) |
| 104 | + ->danger() |
| 105 | + ->send(); |
| 106 | + } |
73 | 107 | }),
|
74 | 108 | Actions\Action::make('delete')
|
75 | 109 | ->label('Delete')
|
|
0 commit comments