Files
Toiminnanohjaus/app/Modules/Shared/Presentation/Livewire/⚡company.blade.php
T
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

141 lines
5.5 KiB
PHP

<?php
use App\Modules\Shared\Application\DTOs\CompanyDetails;
use App\Modules\Shared\Application\UseCases\CompanyDetailsStore;
use App\Modules\Shared\Application\UseCases\DailyCapacity;
use App\Modules\Shared\Domain\Exceptions\CompanyNameRequired;
use App\Modules\Shared\Domain\Exceptions\InvalidBusinessId;
use App\Modules\Shared\Domain\Exceptions\InvalidDailyCapacity;
use App\Modules\Shared\Domain\Exceptions\InvalidEmailAddress;
use Livewire\Attributes\Locked;
use Livewire\Component;
/**
* The company's own details (Yritystiedot) for receipts and other
* documents, and the task calendar's daily capacity. Only admins change
* settings (spec 2).
*/
new class extends Component
{
public string $name = '';
public string $menu_name = '';
public string $business_id = '';
public string $address = '';
public string $phone = '';
public string $email = '';
public string $daily_capacity_hours = '';
#[Locked]
public string $statusMessage = '';
public function mount(CompanyDetailsStore $store, DailyCapacity $capacity): void
{
$this->authorize('settings.manage');
$this->daily_capacity_hours = $capacity->hours() ?? '';
$details = $store->get();
if ($details !== null) {
$this->name = $details->name;
$this->menu_name = $details->menuName ?? '';
$this->business_id = $details->businessId;
$this->address = $details->address ?? '';
$this->phone = $details->phone ?? '';
$this->email = $details->email ?? '';
}
}
public function save(CompanyDetailsStore $store, DailyCapacity $capacity): void
{
$this->authorize('settings.manage');
$this->statusMessage = '';
$this->validate([
'name' => ['required', 'string', 'max:255'],
'menu_name' => ['nullable', 'string', 'max:100'],
'business_id' => ['required', 'string', 'max:20'],
'address' => ['nullable', 'string', 'max:500'],
'phone' => ['nullable', 'string', 'max:50'],
'email' => ['nullable', 'string', 'max:255'],
'daily_capacity_hours' => ['nullable', 'string', 'max:10'],
], [
'name.required' => __('company.errors.name'),
'name.max' => __('company.errors.name'),
'menu_name.max' => __('company.errors.menu_name'),
'business_id.required' => __('company.errors.business_id'),
'business_id.max' => __('company.errors.business_id'),
'address.max' => __('company.errors.address'),
'phone.max' => __('company.errors.phone'),
'email.max' => __('company.errors.email'),
'daily_capacity_hours.max' => __('company.errors.daily_capacity_hours'),
]);
if (! DailyCapacity::isValid($this->daily_capacity_hours)) {
$this->addError('daily_capacity_hours', __('company.errors.daily_capacity_hours'));
return;
}
try {
$store->save(new CompanyDetails($this->name, $this->business_id, $this->address, $this->phone, $this->email, $this->menu_name));
$capacity->save($this->daily_capacity_hours);
} catch (InvalidDailyCapacity) {
$this->addError('daily_capacity_hours', __('company.errors.daily_capacity_hours'));
return;
} catch (CompanyNameRequired) {
$this->addError('name', __('company.errors.name'));
return;
} catch (InvalidBusinessId) {
$this->addError('business_id', __('company.errors.business_id'));
return;
} catch (InvalidEmailAddress) {
$this->addError('email', __('company.errors.email'));
return;
}
$this->business_id = (string) $store->get()?->businessId;
$this->daily_capacity_hours = $capacity->hours() ?? '';
$this->statusMessage = __('company.saved');
}
public function render(): mixed
{
return $this->view()->title(__('company.title'));
}
};
?>
<div class="mx-auto max-w-lg space-y-6 p-4 sm:p-6">
<div class="space-y-1">
<x-page-title icon="building-office">{{ __('company.title') }}</x-page-title>
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('company.intro') }}</p>
</div>
<p role="status" aria-live="polite" class="text-sm font-medium">{{ $statusMessage }}</p>
<form wire:submit="save" class="card space-y-6" novalidate>
<x-input wire:model="name" :label="__('company.fields.name')" autocomplete="organization" required />
<x-input wire:model="menu_name" :label="__('company.fields.menu_name')" :hint="__('company.fields.menu_name_hint')" autocomplete="off" />
<x-input wire:model="business_id" :label="__('company.fields.business_id')" :hint="__('company.fields.business_id_hint')" autocomplete="off" required />
<x-textarea wire:model="address" :label="__('company.fields.address')" :hint="__('company.fields.address_hint')" rows="3" autocomplete="street-address" />
<x-input wire:model="phone" type="tel" :label="__('company.fields.phone')" autocomplete="tel" />
<x-input wire:model="email" type="email" :label="__('company.fields.email')" autocomplete="email" />
<h2 class="pt-2 text-lg font-semibold">{{ __('company.calendar_heading') }}</h2>
<x-input wire:model="daily_capacity_hours" inputmode="decimal" :label="__('company.fields.daily_capacity_hours')" :hint="__('company.fields.daily_capacity_hours_hint')" autocomplete="off" />
<x-button submit :text="__('company.save')" />
</form>
</div>