refactor(article): merubah cara mengirim notifikasi setelah create dan update

This commit is contained in:
Yoga Pangestu 2025-12-15 21:16:18 +07:00
parent ad30631544
commit d266acae85
3 changed files with 21 additions and 8 deletions

View File

@ -34,11 +34,9 @@ public function save(): void
], ],
); );
$this->dispatch('refreshDatatable'); $this->redirectRoute('studio.manage.article.index', [
'notification' => 'Artikel berhasil ditambahkan.',
$this->toast('Artikel berhasil ditambahkan.'); ], navigate: true);
$this->redirectRoute('studio.manage.article.index');
} }
public function render(): View public function render(): View

View File

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

View File

@ -17,6 +17,21 @@ class Index extends Component
{ {
use WithAuthorization, WithConfirmation, WithSubscribeNotification, WithToast; use WithAuthorization, WithConfirmation, WithSubscribeNotification, WithToast;
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);
}
}
public function delete(Article $article): void public function delete(Article $article): void
{ {
$this->canOrAbort('delete article'); $this->canOrAbort('delete article');