feat(generation): add retry action for failed template generations and update related schemas
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TemplateGenerations\Actions;
|
||||
|
||||
use App\Enums\TemplateGenerationStatus;
|
||||
use App\Jobs\GenerateTemplateJob;
|
||||
use App\Models\TemplateGeneration;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
/**
|
||||
* Re-runs the pptx fill step for a failed generation using its already-stored
|
||||
* values (including any AI-generated text), without calling the AI service again.
|
||||
*/
|
||||
class RetryGenerationAction
|
||||
{
|
||||
public static function make(): Action
|
||||
{
|
||||
return Action::make('retry')
|
||||
->label('تلاش دوباره')
|
||||
->icon(Heroicon::OutlinedArrowPath)
|
||||
->color('warning')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('فایل پاورپوینت با همان محتوایی که قبلاً (از جمله متنهای تولیدشده با هوش مصنوعی) ذخیره شده، دوباره ساخته میشود. نیازی به تماس مجدد با هوش مصنوعی نیست.')
|
||||
->visible(fn (TemplateGeneration $record): bool => $record->status === TemplateGenerationStatus::Failed)
|
||||
->action(function (TemplateGeneration $record): void {
|
||||
$record->update([
|
||||
'status' => TemplateGenerationStatus::Pending,
|
||||
'error_message' => null,
|
||||
]);
|
||||
|
||||
GenerateTemplateJob::dispatch($record);
|
||||
|
||||
Notification::make()
|
||||
->title('درخواست دوباره ارسال شد')
|
||||
->success()
|
||||
->send();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user