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->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

View File

@ -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

View File

@ -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');

View File

@ -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

View File

@ -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

View File

@ -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');

View File

@ -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

View File

@ -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

View File

@ -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');