diff --git a/app/Livewire/Studio/Catalog/Bottle/Create.php b/app/Livewire/Studio/Catalog/Bottle/Create.php index 662d855..46411df 100644 --- a/app/Livewire/Studio/Catalog/Bottle/Create.php +++ b/app/Livewire/Studio/Catalog/Bottle/Create.php @@ -32,11 +32,9 @@ public function save(): void $this->form->store(); - $this->dispatch('refreshDatatable'); - - $this->toast('Botol berhasil ditambahkan.'); - - $this->redirectRoute('studio.catalog.bottle.index'); + $this->redirectRoute('studio.catalog.bottle.index', [ + 'notification' => 'Botol berhasil ditambahkan.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Catalog/Bottle/Edit.php b/app/Livewire/Studio/Catalog/Bottle/Edit.php index 6110605..816deff 100644 --- a/app/Livewire/Studio/Catalog/Bottle/Edit.php +++ b/app/Livewire/Studio/Catalog/Bottle/Edit.php @@ -35,11 +35,9 @@ public function save(): void $this->form->update(); - $this->dispatch('refreshDatatable'); - - $this->toast('Botol berhasil diperbarui.'); - - $this->redirectRoute('studio.catalog.bottle.index'); + $this->redirectRoute('studio.catalog.bottle.index', [ + 'notification' => 'Botol berhasil diperbarui.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Catalog/Bottle/Index.php b/app/Livewire/Studio/Catalog/Bottle/Index.php index e739f2d..eab8b04 100644 --- a/app/Livewire/Studio/Catalog/Bottle/Index.php +++ b/app/Livewire/Studio/Catalog/Bottle/Index.php @@ -18,6 +18,21 @@ class Index extends Component { use WithAuthorization, WithConfirmation, WithShowPrice, 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(Bottle $bottle): void { $this->canOrAbort('delete bottle'); diff --git a/app/Livewire/Studio/Catalog/Perfume/Create.php b/app/Livewire/Studio/Catalog/Perfume/Create.php index 89e3924..3289be0 100644 --- a/app/Livewire/Studio/Catalog/Perfume/Create.php +++ b/app/Livewire/Studio/Catalog/Perfume/Create.php @@ -53,11 +53,9 @@ public function save(): void ], ); - $this->dispatch('refreshDatatable'); - - $this->toast('Parfum berhasil ditambahkan.'); - - $this->redirectRoute('studio.catalog.perfume.index'); + $this->redirectRoute('studio.catalog.perfume.index', [ + 'notification' => 'Parfum berhasil ditambahkan.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Catalog/Perfume/Edit.php b/app/Livewire/Studio/Catalog/Perfume/Edit.php index 750155c..3b8c2eb 100644 --- a/app/Livewire/Studio/Catalog/Perfume/Edit.php +++ b/app/Livewire/Studio/Catalog/Perfume/Edit.php @@ -46,11 +46,9 @@ public function save(): void $this->form->update(); - $this->dispatch('refreshDatatable'); - - $this->toast('Parfum berhasil diperbarui.'); - - $this->redirectRoute('studio.catalog.perfume.index'); + $this->redirectRoute('studio.catalog.perfume.index', [ + 'notification' => 'Parfum berhasil diperbarui.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Catalog/Perfume/Index.php b/app/Livewire/Studio/Catalog/Perfume/Index.php index 1e7ca38..dbb6083 100644 --- a/app/Livewire/Studio/Catalog/Perfume/Index.php +++ b/app/Livewire/Studio/Catalog/Perfume/Index.php @@ -17,6 +17,21 @@ class Index extends Component { use WithAuthorization, WithConfirmation, WithShowPrice, 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(Perfume $perfume) { $this->canOrAbort('delete perfume'); diff --git a/app/Livewire/Studio/Catalog/Product/Create.php b/app/Livewire/Studio/Catalog/Product/Create.php index 20c67c9..e655cb8 100644 --- a/app/Livewire/Studio/Catalog/Product/Create.php +++ b/app/Livewire/Studio/Catalog/Product/Create.php @@ -32,11 +32,9 @@ public function save(): void $this->form->store(); - $this->dispatch('refreshDatatable'); - - $this->toast('Produk berhasil ditambahkan.'); - - $this->redirectRoute('studio.catalog.product.index'); + $this->redirectRoute('studio.catalog.product.index', [ + 'notification' => 'Produk berhasil ditambahkan.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Catalog/Product/Edit.php b/app/Livewire/Studio/Catalog/Product/Edit.php index 4e6c261..8fdfe57 100644 --- a/app/Livewire/Studio/Catalog/Product/Edit.php +++ b/app/Livewire/Studio/Catalog/Product/Edit.php @@ -35,11 +35,9 @@ public function save(): void $this->form->update(); - $this->dispatch('refreshDatatable'); - - $this->toast('Produk berhasil diperbarui.'); - - $this->redirectRoute('studio.catalog.product.index'); + $this->redirectRoute('studio.catalog.product.index', [ + 'notification' => 'Produk berhasil diperbarui.', + ], navigate: true); } public function render(): View diff --git a/app/Livewire/Studio/Catalog/Product/Index.php b/app/Livewire/Studio/Catalog/Product/Index.php index cedfdcf..537f993 100644 --- a/app/Livewire/Studio/Catalog/Product/Index.php +++ b/app/Livewire/Studio/Catalog/Product/Index.php @@ -18,6 +18,21 @@ class Index extends Component { use WithAuthorization, WithConfirmation, WithShowPrice, 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(Product $product): void { $this->canOrAbort('delete product');