refactor: Replace Notification with CheerfulNotification for improved user feedback and enhance error logging in various services
This commit is contained in:
parent
6574684f46
commit
8ddad47c01
@ -18,9 +18,9 @@
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use UnitEnum;
|
||||
|
||||
class AdminVerification extends Page implements HasActions, HasForms
|
||||
@ -230,10 +230,10 @@ protected function processReview(int $requestId, DecisionAdmin $decision, ?strin
|
||||
$verificationRequest = VerificationRequest::with(['company.partnerMedia.journalists'])->find($requestId);
|
||||
|
||||
if (! $verificationRequest) {
|
||||
Notification::make()
|
||||
->title('Error')
|
||||
->body('Data verifikasi tidak ditemukan.')
|
||||
->danger()
|
||||
CheerfulNotification::danger(
|
||||
'Belum ketemu nih 🙌',
|
||||
'Data verifikasi belum kami temukan. Coba sebentar lagi, ya.',
|
||||
)
|
||||
->send();
|
||||
|
||||
return;
|
||||
@ -283,11 +283,18 @@ protected function processReview(int $requestId, DecisionAdmin $decision, ?strin
|
||||
],
|
||||
]));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Notification::make()
|
||||
->title('Error')
|
||||
->body('Terjadi kesalahan saat memproses verifikasi: '.$e->getMessage())
|
||||
->danger()
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Verification processing failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'request_id' => $requestId,
|
||||
'decision' => $decision->value,
|
||||
]);
|
||||
|
||||
CheerfulNotification::danger(
|
||||
'Belum ketemu nih 🙌',
|
||||
'Data verifikasi belum kami temukan atau terjadi kesalahan sistem. Coba sebentar lagi, ya.',
|
||||
)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Filament\Support\CheerfulNotification;
|
||||
use App\Models\Company as CompanyModel;
|
||||
use App\Models\VerificationRequest;
|
||||
use Asmit\FilamentUpload\Forms\Components\AdvancedFileUpload;
|
||||
@ -9,7 +10,6 @@
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
@ -311,9 +311,6 @@ public function save()
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Informasi perusahaan berhasil diperbarui.')
|
||||
->success()
|
||||
->send();
|
||||
CheerfulNotification::update()->send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\MediaClassification;
|
||||
use App\Enums\MediaType;
|
||||
use App\Filament\Support\CheerfulNotification;
|
||||
use App\Models\Company;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\VerificationRequest;
|
||||
@ -13,7 +14,6 @@
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
@ -244,9 +244,6 @@ public function save()
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Informasi media berhasil diperbarui.')
|
||||
->success()
|
||||
->send();
|
||||
CheerfulNotification::update()->send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Manage\Journalists\Pages;
|
||||
|
||||
use App\Enums\VerificationStatus;
|
||||
use App\Filament\Actions\Cheerful\CreateAction;
|
||||
use App\Filament\Resources\Manage\Journalists\JournalistResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
@ -25,7 +26,7 @@ protected function getHeaderActions(): array
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if ($verificationRequest && $verificationRequest->status !== \App\Enums\VerificationStatus::NEED_REVISION) {
|
||||
if ($verificationRequest && $verificationRequest->status !== VerificationStatus::NEED_REVISION) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Monitoring\IssueManagements\Tables;
|
||||
|
||||
use App\Enums\IssueSentiment;
|
||||
use App\Filament\Actions\Cheerful\DeleteAction;
|
||||
use App\Filament\Actions\Cheerful\EditAction;
|
||||
use App\Filament\Actions\Cheerful\ForceDeleteAction;
|
||||
@ -57,12 +58,12 @@ public static function configure(Table $table): Table
|
||||
|
||||
SelectFilter::make('issue')
|
||||
->label('Filter Isu')
|
||||
->options(\App\Enums\IssueSentiment::class)
|
||||
->options(IssueSentiment::class)
|
||||
->native(false),
|
||||
|
||||
SelectFilter::make('response')
|
||||
->label('Filter Respon')
|
||||
->options(\App\Enums\IssueSentiment::class)
|
||||
->options(IssueSentiment::class)
|
||||
->native(false),
|
||||
])
|
||||
->recordActions([
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Publication\News\Tables;
|
||||
|
||||
use App\Enums\NewsStatus;
|
||||
use App\Filament\Actions\Cheerful\DeleteAction;
|
||||
use App\Filament\Actions\Cheerful\EditAction;
|
||||
use App\Filament\Actions\Cheerful\ForceDeleteAction;
|
||||
@ -69,8 +70,8 @@ public static function configure(Table $table): Table
|
||||
->searchable()
|
||||
->sortable()
|
||||
->badge()
|
||||
->formatStateUsing(fn (\App\Enums\NewsStatus $state): string => $state->getLabel())
|
||||
->color(fn (\App\Enums\NewsStatus $state): string => $state->getColor()),
|
||||
->formatStateUsing(fn (NewsStatus $state): string => $state->getLabel())
|
||||
->color(fn (NewsStatus $state): string => $state->getColor()),
|
||||
|
||||
TextColumn::make('published_at')
|
||||
->label('Tgl Publish')
|
||||
|
||||
@ -113,14 +113,21 @@ public function crawlFromGoogleNews(string $keyword, int $limit = 10, array $the
|
||||
}
|
||||
|
||||
$count++;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Failed to insert item: '.$e->getMessage());
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Failed to insert item', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'link' => $itemData['original_link'] ?? 'unknown',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Crawler error: '.$e->getMessage());
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Crawler error', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -180,7 +187,10 @@ private function extractContent(Crawler $crawler): ?string
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('Failed to check paragraphs content', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
use App\Models\VerificationReview;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class VerificationService
|
||||
{
|
||||
@ -256,7 +257,14 @@ public function processReview(VerificationRequest $verificationRequest, Decision
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Verification review processing failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'request_id' => $verificationRequest->id,
|
||||
'decision' => $decision->value,
|
||||
]);
|
||||
|
||||
DB::rollBack();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user