refactor(article): merubah cara mengirim notifikasi setelah create dan update
This commit is contained in:
parent
ad30631544
commit
d266acae85
@ -34,11 +34,9 @@ public function save(): void
|
||||
],
|
||||
);
|
||||
|
||||
$this->dispatch('refreshDatatable');
|
||||
|
||||
$this->toast('Artikel berhasil ditambahkan.');
|
||||
|
||||
$this->redirectRoute('studio.manage.article.index');
|
||||
$this->redirectRoute('studio.manage.article.index', [
|
||||
'notification' => 'Artikel berhasil ditambahkan.',
|
||||
], navigate: true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
||||
@ -29,9 +29,9 @@ public function save(): void
|
||||
|
||||
$this->form->update();
|
||||
|
||||
$this->toast('Artikel berhasil diperbarui.');
|
||||
|
||||
$this->redirectRoute('studio.manage.article.index');
|
||||
$this->redirectRoute('studio.manage.article.index', [
|
||||
'notification' => 'Artikel berhasil diperbarui.',
|
||||
], navigate: true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
||||
@ -17,6 +17,21 @@ class Index extends Component
|
||||
{
|
||||
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
|
||||
{
|
||||
$this->canOrAbort('delete article');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user