- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 / primary-100 and TallStackUI's dark labels, hints and checkbox labels are lightened so everything stays at 4.5:1. - Shared HexColor picks white or black text by the higher WCAG contrast; a native-dialog colour picker and a large work dialog component. - Customers get a header colour (customers.header_color), set on the customer page. - New job status Jatkuvat / Kausi (ongoing): open, never late, billed monthly like running jobs. - Kanban model: board columns and views, urgent threshold, per-user board preferences (density, column colours and sort), card positions, tasks of continuing jobs pinned to the board, MoveBoardCard and board queries with logged hours from TimeTracking. Co-Authored-By: Claude Opus 5.5 <[email protected]>
141 lines
5.5 KiB
PHP
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-200">{{ __('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>
|