Commit 23c68694 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix 3 bugs: participant branch, layout update, receipt branch

1. ParticipantForm: set branch_id from session in mount() so new
   participants get the active branch (was null, invisible in list)
2. SpaceLayoutService::update: compare config BEFORE updating the model
   so change detection works (was comparing same value to itself)
3. ReceiptSettings: use session branch_id instead of user->branch_id
   which could be null, preventing template save
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent f98f2b2b
...@@ -40,12 +40,14 @@ public function update(SpaceLayout $layout, array $data): SpaceLayout ...@@ -40,12 +40,14 @@ public function update(SpaceLayout $layout, array $data): SpaceLayout
$oldType = $layout->layout_type->value; $oldType = $layout->layout_type->value;
$oldConfig = $layout->layout_config; $oldConfig = $layout->layout_config;
$layout->update($data);
$newType = $data['layout_type'] ?? $oldType; $newType = $data['layout_type'] ?? $oldType;
$newConfig = $data['layout_config'] ?? $oldConfig; $newConfig = $data['layout_config'] ?? $oldConfig;
if ($newType !== $oldType || $newConfig !== $oldConfig) { $layout->update($data);
$configChanged = $newType !== $oldType || json_encode($newConfig) !== json_encode($oldConfig);
if ($configChanged) {
$layout->segments()->delete(); $layout->segments()->delete();
$this->generateSegments($layout->fresh()); $this->generateSegments($layout->fresh());
} }
......
...@@ -50,6 +50,8 @@ class ParticipantForm extends Component ...@@ -50,6 +50,8 @@ class ParticipantForm extends Component
public function mount(?Participant $participant = null): void public function mount(?Participant $participant = null): void
{ {
$this->branch_id = session('active_branch_id', auth()->user()->branch_id);
if ($participant && $participant->exists) { if ($participant && $participant->exists) {
$this->participant = $participant->load('person'); $this->participant = $participant->load('person');
$this->editing = true; $this->editing = true;
......
...@@ -22,8 +22,7 @@ public function mount(): void ...@@ -22,8 +22,7 @@ public function mount(): void
{ {
$this->authorize('settings.manage'); $this->authorize('settings.manage');
$user = auth()->user(); $this->selectedBranchId = session('active_branch_id', auth()->user()->branch_id);
$this->selectedBranchId = $user->branch_id;
$this->loadTemplate(); $this->loadTemplate();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment