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+ Settings for {{ strtoupper($file->extension) }} to {{ strtoupper($selectedTargetFormat) }} +
+Conversion settings will be added in Phase 8.
+