feat(generation): add retry action for failed template generations and update related schemas

This commit is contained in:
2026-08-21 14:53:19 +03:30
parent e58dcd8581
commit fe2090a5af
5 changed files with 100 additions and 0 deletions

View File

@@ -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();
});
}
}