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