<?php

namespace App\Filament\Pages;

use App\Services\QuestionImportService;
use App\Jobs\ProcessMarkdownJob;
use Filament\Pages\Page;
use UnitEnum;

class ImportWizard extends Page
{
    protected static bool $shouldRegisterNavigation = false;

    protected static ?string $navigationLabel = 'Markdown/PDF 导入';

    protected static UnitEnum|string|null $navigationGroup = '卷子导入流程';

    protected static ?int $navigationSort = 1;

    protected string $view = 'filament.pages.import-wizard';

    public ?string $filePath = null;

    public function submitImport(): void
    {
        if (!$this->filePath) {
            return;
        }

        $service = app(QuestionImportService::class);
        $result = $service->importMarkdown($this->filePath);
        ProcessMarkdownJob::dispatch($result->importId, $result->sourceFileId);
    }
}
