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->toast('Outlet berhasil ditambahkan.');
$this->redirectRoute('studio.master.outlet.index');
$this->redirectRoute('studio.master.outlet.index', [
'notification' => 'Outlet berhasil ditambahkan.',
], navigate: true);
}
public function render(): View

View File

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

View File

@ -29,6 +29,18 @@ class Index extends Component
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();
}

View File

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

View File

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

View File

@ -28,6 +28,18 @@ class Index extends Component
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();
}