feat(notification): Implement URL-based toast notifications for bottle, perfume, and product creation and updates, enhancing user feedback and navigation.

This commit is contained in:
Yoga Pangestu 2025-12-14 14:33:20 +07:00
parent 3916ef436e
commit 8aa25b662a
9 changed files with 63 additions and 30 deletions

View File

@ -32,11 +32,9 @@ public function save(): void
$this->form->store(); $this->form->store();
$this->dispatch('refreshDatatable'); $this->redirectRoute('studio.catalog.bottle.index', [
'notification' => 'Botol berhasil ditambahkan.',
$this->toast('Botol berhasil ditambahkan.'); ], navigate: true);
$this->redirectRoute('studio.catalog.bottle.index');
} }
public function render(): View public function render(): View

View File

@ -35,11 +35,9 @@ public function save(): void
$this->form->update(); $this->form->update();
$this->dispatch('refreshDatatable'); $this->redirectRoute('studio.catalog.bottle.index', [
'notification' => 'Botol berhasil diperbarui.',
$this->toast('Botol berhasil diperbarui.'); ], navigate: true);
$this->redirectRoute('studio.catalog.bottle.index');
} }
public function render(): View public function render(): View

View File

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

View File

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

View File

@ -46,11 +46,9 @@ public function save(): void
$this->form->update(); $this->form->update();
$this->dispatch('refreshDatatable'); $this->redirectRoute('studio.catalog.perfume.index', [
'notification' => 'Parfum berhasil diperbarui.',
$this->toast('Parfum berhasil diperbarui.'); ], navigate: true);
$this->redirectRoute('studio.catalog.perfume.index');
} }
public function render(): View public function render(): View

View File

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

View File

@ -32,11 +32,9 @@ public function save(): void
$this->form->store(); $this->form->store();
$this->dispatch('refreshDatatable'); $this->redirectRoute('studio.catalog.product.index', [
'notification' => 'Produk berhasil ditambahkan.',
$this->toast('Produk berhasil ditambahkan.'); ], navigate: true);
$this->redirectRoute('studio.catalog.product.index');
} }
public function render(): View public function render(): View

View File

@ -35,11 +35,9 @@ public function save(): void
$this->form->update(); $this->form->update();
$this->dispatch('refreshDatatable'); $this->redirectRoute('studio.catalog.product.index', [
'notification' => 'Produk berhasil diperbarui.',
$this->toast('Produk berhasil diperbarui.'); ], navigate: true);
$this->redirectRoute('studio.catalog.product.index');
} }
public function render(): View public function render(): View

View File

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