From 8bde46fd18ee9fbedc5c68721706bf55e6d35579 Mon Sep 17 00:00:00 2001 From: Ivan Moroz Date: Sun, 31 May 2026 18:30:54 +0300 Subject: [PATCH] CONV-091: Implement target format selection Co-Authored-By: Claude Opus 4.8 --- app/Livewire/Dashboard/DashboardConverter.php | 33 +++++++++++++++++++ .../dashboard/dashboard-converter.blade.php | 16 +++++++++ .../DashboardConverterTargetFormatTest.php | 4 +-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/Livewire/Dashboard/DashboardConverter.php b/app/Livewire/Dashboard/DashboardConverter.php index 71a86c3..1f054e9 100644 --- a/app/Livewire/Dashboard/DashboardConverter.php +++ b/app/Livewire/Dashboard/DashboardConverter.php @@ -25,6 +25,10 @@ class DashboardConverter extends Component public ?string $uploadError = null; + public ?string $selectedTargetFormat = null; + + public ?string $targetFormatError = null; + public function storeUpload(StoreUploadedFileAction $storeUploadedFile): void { $this->resetErrorBag(); @@ -81,6 +85,35 @@ public function ensureValidStep(): void } } + public function selectTargetFormat(string $targetFormat): void + { + $this->targetFormatError = null; + + if ($this->currentFile === null) { + $this->currentFileId = null; + $this->selectedTargetFormat = null; + $this->step = 'upload'; + + return; + } + + $converter = app(ConverterRegistry::class)->find( + $this->currentFile->extension, + $targetFormat, + ); + + if ($converter === null) { + $this->selectedTargetFormat = null; + $this->targetFormatError = 'This conversion is not supported yet.'; + $this->step = 'format'; + + return; + } + + $this->selectedTargetFormat = $converter->targetFormat(); + $this->step = 'settings'; + } + public function replaceFile(): void { $this->resetCurrentUpload(); diff --git a/resources/views/livewire/dashboard/dashboard-converter.blade.php b/resources/views/livewire/dashboard/dashboard-converter.blade.php index ec566e3..94609b5 100644 --- a/resources/views/livewire/dashboard/dashboard-converter.blade.php +++ b/resources/views/livewire/dashboard/dashboard-converter.blade.php @@ -66,6 +66,10 @@ class="flex flex-col items-center justify-center gap-4 rounded-[var(--ca-radius- + @if ($targetFormatError) +

{{ $targetFormatError }}

+ @endif + @if (empty($this->targetFormatCards))

No conversion targets available

@@ -100,5 +104,17 @@ class="flex items-start gap-3 rounded-[var(--ca-radius-md)] border border-[var(- @endif
@endif + + @if ($step === 'settings' && $this->currentFile) + @php($file = $this->currentFile) +
+
+

+ Settings for {{ strtoupper($file->extension) }} to {{ strtoupper($selectedTargetFormat) }} +

+

Conversion settings will be added in Phase 8.

+
+
+ @endif diff --git a/tests/Feature/Livewire/DashboardConverterTargetFormatTest.php b/tests/Feature/Livewire/DashboardConverterTargetFormatTest.php index dc7afe2..da8171a 100644 --- a/tests/Feature/Livewire/DashboardConverterTargetFormatTest.php +++ b/tests/Feature/Livewire/DashboardConverterTargetFormatTest.php @@ -17,7 +17,7 @@ ->assertSet('selectedTargetFormat', 'jpg') ->assertSet('step', 'settings') ->assertSee('Settings for PNG to JPG'); -})->skip('Implemented in CONV-091'); +}); it('rejects an unsupported target format selection', function () { $user = User::factory()->create(); @@ -31,4 +31,4 @@ ->assertSet('selectedTargetFormat', null) ->assertSet('step', 'format') ->assertSee('This conversion is not supported'); -})->skip('Implemented in CONV-091'); +});