10-04-2026
This commit is contained in:
parent
4d6b4930b2
commit
4bb89aad8c
836 changed files with 52961 additions and 5950 deletions
109
app/Livewire/Cabinet/QuickStatus.php
Normal file
109
app/Livewire/Cabinet/QuickStatus.php
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire\Cabinet;
|
||||
|
||||
use App\Models\CabinetTabletSetting;
|
||||
use Livewire\Component;
|
||||
|
||||
class QuickStatus extends Component
|
||||
{
|
||||
public bool $authorized = false;
|
||||
|
||||
public string $storeStatus = 'auto';
|
||||
|
||||
public string $noticeHeadline = '';
|
||||
|
||||
public string $noticeSubtext = '';
|
||||
|
||||
public bool $saved = false;
|
||||
|
||||
/** @var array<string, array{label: string, color: string, icon: string, description: string}> */
|
||||
public array $statusOptions = [
|
||||
'auto' => [
|
||||
'label' => 'Automatisch',
|
||||
'color' => 'green',
|
||||
'icon' => '✓',
|
||||
'description' => 'Status aus Öffnungszeiten',
|
||||
],
|
||||
'closed' => [
|
||||
'label' => 'Geschlossen',
|
||||
'color' => 'yellow',
|
||||
'icon' => '–',
|
||||
'description' => 'Manuell geschlossen',
|
||||
],
|
||||
'notice' => [
|
||||
'label' => 'Hinweis',
|
||||
'color' => 'orange',
|
||||
'icon' => '!',
|
||||
'description' => 'Info-Nachricht anzeigen',
|
||||
],
|
||||
'warning' => [
|
||||
'label' => 'Warnung',
|
||||
'color' => 'red',
|
||||
'icon' => '!',
|
||||
'description' => 'Dringende Warnung',
|
||||
],
|
||||
];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$validKey = config('domains.cabinet_status_key');
|
||||
$key = request()->get('key');
|
||||
if (! $validKey || $key !== $validKey) {
|
||||
$this->authorized = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->authorized = true;
|
||||
$settings = CabinetTabletSetting::current();
|
||||
$this->storeStatus = $settings->store_status ?? 'auto';
|
||||
$this->noticeHeadline = $settings->notice_headline ?? '';
|
||||
$this->noticeSubtext = $settings->notice_subtext ?? '';
|
||||
}
|
||||
|
||||
public function selectStatus(string $status): void
|
||||
{
|
||||
if (! $this->authorized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! array_key_exists($status, $this->statusOptions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->storeStatus = $status;
|
||||
$this->saved = false;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
if (! $this->authorized) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validate([
|
||||
'storeStatus' => 'required|in:auto,notice,warning,closed',
|
||||
'noticeHeadline' => 'nullable|string|max:40',
|
||||
'noticeSubtext' => 'nullable|string|max:80',
|
||||
], [
|
||||
'storeStatus.in' => 'Ungültiger Status.',
|
||||
'noticeHeadline.max' => 'Headline max. 40 Zeichen.',
|
||||
'noticeSubtext.max' => 'Subtext max. 80 Zeichen.',
|
||||
]);
|
||||
|
||||
CabinetTabletSetting::current()->update([
|
||||
'store_status' => $this->storeStatus,
|
||||
'notice_headline' => $this->noticeHeadline ?: null,
|
||||
'notice_subtext' => $this->noticeSubtext ?: null,
|
||||
]);
|
||||
|
||||
$this->saved = true;
|
||||
}
|
||||
|
||||
public function render(): \Illuminate\View\View
|
||||
{
|
||||
return view('livewire.cabinet.quick-status')
|
||||
->layout('layouts.cabinet-quick');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue