Files
petriandClaude Opus 5.5 51b40b24fe Give the UI an indigo look with cards, status badges and empty states
- Dark indigo header and tinted page background; the mobile main menu gets
  its own row, in the same order as the keyboard reaches it.
- Page titles with an icon chip (x-page-title, x-page, x-page-header) and
  card sections (x-panel, the card utility); x-table styled as a card with
  an indigo header row in AppServiceProvider::styleTables().
- Job and task statuses, late work, unapproved hours and stock states as
  badges with icon and text (x-status-badge, x-jobs.status,
  x-jobs.task-status), never colour alone.
- Empty lists as x-empty-state; dashboard quick link tiles, week hour bars
  and trend arrows; Kanban columns and task cards edged by status; calendar
  today column and bar accents; quick sale, reports and machine console
  restyled; signed-out pages show the app name.
- Focus rings use the primary colour in both themes (white in the header).
- Document the components in CLAUDE.md; test the status badges.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 10:53:10 +02:00

151 lines
5.8 KiB
PHP

<?php
use App\Modules\Billing\Application\Contracts\BillingQueries;
use App\Modules\Billing\Application\DTOs\ExportSummary;
use App\Modules\Billing\Application\UseCases\OpenBillingDraft;
use App\Modules\Billing\Domain\Enums\ExportStatus;
use App\Modules\Billing\Domain\Exceptions\DraftAlreadyOpen;
use App\Modules\Billing\Presentation\Livewire\Concerns\FormatsBilling;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Locked;
use Livewire\Component;
/**
* Billing materials (laskuaineistot), newest first, and the way to start
* a new draft or continue the open one. Management only.
*/
new class extends Component
{
use FormatsBilling;
#[Locked]
public string $statusMessage = '';
public function mount(): void
{
$this->authorize('billing.manage');
$this->statusMessage = (string) session('billing-status', '');
}
/**
* @return list<ExportSummary>
*/
#[Computed]
public function exports(): array
{
return app(BillingQueries::class)->exports();
}
#[Computed]
public function openDraft(): ?ExportSummary
{
foreach ($this->exports as $export) {
if ($export->status === ExportStatus::Draft) {
return $export;
}
}
return null;
}
public function openDraftNow(OpenBillingDraft $openBillingDraft): void
{
$this->authorize('billing.manage');
try {
$id = $openBillingDraft->execute((int) auth()->id());
$this->redirectRoute('billing.export', ['export' => $id], navigate: true);
} catch (DraftAlreadyOpen) {
$this->statusMessage = __('billing.errors.draft_open');
unset($this->exports, $this->openDraft);
}
}
/**
* @return list<array{index: string, label: string, sortable: bool, align?: string}>
*/
public function headers(): array
{
return [
['index' => 'number', 'label' => __('billing.index.columns.number'), 'sortable' => false],
['index' => 'status', 'label' => __('billing.index.columns.status'), 'sortable' => false],
['index' => 'created', 'label' => __('billing.index.columns.created'), 'sortable' => false],
['index' => 'finalized', 'label' => __('billing.index.columns.finalized'), 'sortable' => false],
['index' => 'invoices', 'label' => __('billing.index.columns.invoices'), 'sortable' => false, 'align' => 'right'],
['index' => 'jobs', 'label' => __('billing.index.columns.jobs'), 'sortable' => false, 'align' => 'right'],
['index' => 'net', 'label' => __('billing.index.columns.net'), 'sortable' => false, 'align' => 'right'],
['index' => 'file', 'label' => __('billing.index.columns.file'), 'sortable' => false],
];
}
public function render(): mixed
{
return $this->view()->title(__('billing.index.title'));
}
};
?>
<div class="mx-auto max-w-6xl space-y-6 p-4 sm:p-6">
<div class="space-y-2">
<x-page-title icon="banknotes">{{ __('billing.index.title') }}</x-page-title>
<p class="max-w-3xl text-sm">{{ __('billing.index.intro') }}</p>
</div>
<p>
@if ($this->openDraft !== null)
<x-button :href="route('billing.export', $this->openDraft->id)" wire:navigate icon="pencil-square" :text="__('billing.index.continue')" />
@else
<x-button wire:click="openDraftNow" icon="plus" :text="__('billing.index.new')" />
@endif
</p>
<p role="status" aria-live="polite" class="text-sm font-medium">{{ $statusMessage }}</p>
@if ($this->exports === [])
<x-empty-state icon="banknotes">{{ __('billing.index.none') }}</x-empty-state>
@else
<x-table :headers="$this->headers()" :rows="$this->exports">
@interact('column_number', $export)
<x-link :href="route('billing.export', $export->id)" navigate>{{ $export->number === null ? __('billing.index.draft_label') : __('billing.index.export_label', ['number' => $export->number]) }}</x-link>
@endinteract
@interact('column_status', $export)
<span class="inline-flex items-center gap-1">
<x-icon :name="$export->status->value === 'draft' ? 'pencil-square' : 'lock-closed'" class="size-4" aria-hidden="true" />
{{ __('billing.statuses.'.$export->status->value) }}
</span>
@endinteract
@interact('column_created', $export)
<span class="whitespace-nowrap">{{ $this->timeLabel($export->createdAt) }}</span>
<span class="block text-xs">{{ $export->createdByName }}</span>
@endinteract
@interact('column_finalized', $export)
@if ($export->finalizedAt !== null)
<span class="whitespace-nowrap">{{ $this->timeLabel($export->finalizedAt) }}</span>
<span class="block text-xs">{{ $export->finalizedByName }}</span>
@endif
@endinteract
@interact('column_invoices', $export)
{{ $export->invoiceCount }}
@endinteract
@interact('column_jobs', $export)
{{ $export->jobCount }}
@endinteract
@interact('column_net', $export)
<span class="whitespace-nowrap">{{ $export->netCents === null ? '' : $this->money($export->netCents) }}</span>
@endinteract
@interact('column_file', $export)
@if ($export->status->value === 'created')
<x-link :href="route('billing.csv', $export->id)" icon="arrow-down-tray" :aria-label="__('billing.csv.download_named', ['number' => $export->number])">{{ __('billing.csv.download_short') }}</x-link>
@endif
@endinteract
</x-table>
@endif
</div>