Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions app/Livewire/Dashboard/DashboardConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 16 additions & 0 deletions resources/views/livewire/dashboard/dashboard-converter.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class="flex flex-col items-center justify-center gap-4 rounded-[var(--ca-radius-
</div>
</div>

@if ($targetFormatError)
<p class="text-sm text-[var(--ca-danger)]">{{ $targetFormatError }}</p>
@endif

@if (empty($this->targetFormatCards))
<div class="rounded-[var(--ca-radius-md)] border border-dashed border-[var(--ca-border)] bg-[var(--ca-surface-muted)]/40 px-6 py-8 text-center">
<p class="text-base font-semibold text-[var(--ca-text)]">No conversion targets available</p>
Expand Down Expand Up @@ -100,5 +104,17 @@ class="flex items-start gap-3 rounded-[var(--ca-radius-md)] border border-[var(-
@endif
</div>
@endif

@if ($step === 'settings' && $this->currentFile)
@php($file = $this->currentFile)
<div class="flex flex-col gap-4">
<div class="rounded-[var(--ca-radius-md)] border border-dashed border-[var(--ca-border)] bg-[var(--ca-surface-muted)]/40 px-6 py-8 text-center">
<p class="text-base font-semibold text-[var(--ca-text)]">
Settings for {{ strtoupper($file->extension) }} to {{ strtoupper($selectedTargetFormat) }}
</p>
<p class="mt-1 text-sm text-[var(--ca-muted)]">Conversion settings will be added in Phase 8.</p>
</div>
</div>
@endif
</x-card>
</div>
4 changes: 2 additions & 2 deletions tests/Feature/Livewire/DashboardConverterTargetFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -31,4 +31,4 @@
->assertSet('selectedTargetFormat', null)
->assertSet('step', 'format')
->assertSee('This conversion is not supported');
})->skip('Implemented in CONV-091');
});