feat(outlet, user): Implement URL-based toast notifications for creation and updates.
This commit is contained in:
parent
f74e46bcb3
commit
92b069eef5
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user