feat(outlet, user): Implement URL-based toast notifications for creation and updates.

This commit is contained in:
Yoga Pangestu 2025-12-11 22:22:46 +07:00
parent f74e46bcb3
commit 92b069eef5
6 changed files with 36 additions and 12 deletions

View File

@ -40,9 +40,9 @@ public function save(): void
$this->form->store(); $this->form->store();
$this->toast('Outlet berhasil ditambahkan.'); $this->redirectRoute('studio.master.outlet.index', [
'notification' => 'Outlet berhasil ditambahkan.',
$this->redirectRoute('studio.master.outlet.index'); ], navigate: true);
} }
public function render(): View public function render(): View

View File

@ -33,9 +33,9 @@ public function save(): void
$this->form->update(); $this->form->update();
$this->toast('Outlet berhasil diperbarui.'); $this->redirectRoute('studio.master.outlet.index', [
'notification' => 'Outlet berhasil diperbarui.',
$this->redirectRoute('studio.master.outlet.index'); ], navigate: true);
} }
public function render(): View public function render(): View

View File

@ -29,6 +29,18 @@ class Index extends Component
public function mount(): void public function mount(): void
{ {
$hasNotification = request()->get('notification');
if ($hasNotification) {
$this->js(<<<'JS'
const url = new URL(window.location);
url.search = '';
window.history.replaceState({}, '', url);
JS);
$this->toast($hasNotification);
}
$this->loadOutlets(); $this->loadOutlets();
} }

View File

@ -38,9 +38,9 @@ public function save(): void
$this->form->store(); $this->form->store();
$this->toast('Pegawai berhasil ditambahkan.'); $this->redirectRoute('studio.master.user.index', [
'notification' => 'Pegawai berhasil ditambahkan.',
$this->redirectRoute('studio.master.user.index'); ]);
} }
public function render(): View public function render(): View

View File

@ -41,9 +41,9 @@ public function save(): void
$this->form->update(); $this->form->update();
$this->toast('Pegawai berhasil diperbarui.'); $this->redirectRoute('studio.master.user.index', [
'notification' => 'Pegawai berhasil diperbarui.',
$this->redirectRoute('studio.master.user.index'); ]);
} }
public function render(): View public function render(): View

View File

@ -28,6 +28,18 @@ class Index extends Component
public function mount(): void public function mount(): void
{ {
$hasNotification = request()->get('notification');
if ($hasNotification) {
$this->js(<<<'JS'
const url = new URL(window.location);
url.search = '';
window.history.replaceState({}, '', url);
JS);
$this->toast($hasNotification);
}
$this->loadEmployees(); $this->loadEmployees();
} }