From f4e4e457f3840c4fda0098b7e7be76452ca2a592 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Fri, 24 Jul 2026 20:55:47 +0000 Subject: [PATCH] Replace native confirms with Ladill custom dialogs. --- resources/js/ladill-modals.js | 13 +- .../views/components/app-layout.blade.php | 1 + .../components/hosting-panel-layout.blade.php | 1 + .../views/components/user-layout.blade.php | 1 + .../views/merchant/products/index.blade.php | 3 +- .../views/merchant/storefronts/show.blade.php | 5 +- .../views/partials/confirm-prompt.blade.php | 248 ++++++++++++++---- 7 files changed, 216 insertions(+), 56 deletions(-) diff --git a/resources/js/ladill-modals.js b/resources/js/ladill-modals.js index eb2bf74..0eda97a 100644 --- a/resources/js/ladill-modals.js +++ b/resources/js/ladill-modals.js @@ -33,6 +33,10 @@ export function ladillNeedsTopup(balance, price) { return normalizedBalance <= 0 || normalizedBalance < normalizedPrice; } +/** + * Alpine store mirrors window.ladillConfirm (defined in partials/confirm-prompt). + * Prefer window.ladillConfirm for new code — it works without Alpine and powers data-confirm forms. + */ export function registerLadillConfirmStore(Alpine) { Alpine.store('ladillConfirm', { open: false, @@ -44,6 +48,11 @@ export function registerLadillConfirmStore(Alpine) { _resolve: null, ask(options = {}) { + // Delegate to the global custom dialog when available (no double UI). + if (typeof window.ladillConfirm === 'function' && window.__ladillConfirmInstalled) { + return window.ladillConfirm(options); + } + return new Promise((resolve) => { this.title = options.title || 'Are you sure?'; this.message = options.message || ''; @@ -65,7 +74,9 @@ export function registerLadillConfirmStore(Alpine) { }, }); - window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options); + if (typeof window.ladillConfirm !== 'function') { + window.ladillConfirm = (options = {}) => Alpine.store('ladillConfirm').ask(options); + } } export function registerLadillModalHelpers() { diff --git a/resources/views/components/app-layout.blade.php b/resources/views/components/app-layout.blade.php index 96a7909..dd13f70 100644 --- a/resources/views/components/app-layout.blade.php +++ b/resources/views/components/app-layout.blade.php @@ -29,5 +29,6 @@ @auth @include('partials.afia') @endauth + @include('partials.confirm-prompt') diff --git a/resources/views/components/hosting-panel-layout.blade.php b/resources/views/components/hosting-panel-layout.blade.php index 978ac9e..e5e68e6 100644 --- a/resources/views/components/hosting-panel-layout.blade.php +++ b/resources/views/components/hosting-panel-layout.blade.php @@ -69,5 +69,6 @@ @stack('scripts') + @include('partials.confirm-prompt') diff --git a/resources/views/components/user-layout.blade.php b/resources/views/components/user-layout.blade.php index 96a7909..dd13f70 100644 --- a/resources/views/components/user-layout.blade.php +++ b/resources/views/components/user-layout.blade.php @@ -29,5 +29,6 @@ @auth @include('partials.afia') @endauth + @include('partials.confirm-prompt') diff --git a/resources/views/merchant/products/index.blade.php b/resources/views/merchant/products/index.blade.php index 6f47350..84b8911 100644 --- a/resources/views/merchant/products/index.blade.php +++ b/resources/views/merchant/products/index.blade.php @@ -95,8 +95,7 @@
Edit -
+ @csrf @method('DELETE') diff --git a/resources/views/merchant/storefronts/show.blade.php b/resources/views/merchant/storefronts/show.blade.php index 833e759..8b1b590 100644 --- a/resources/views/merchant/storefronts/show.blade.php +++ b/resources/views/merchant/storefronts/show.blade.php @@ -119,7 +119,7 @@
@endunless -
+ @csrf @method('DELETE')
@@ -140,8 +140,7 @@
@endif -
+ @csrf @method('DELETE')
diff --git a/resources/views/partials/confirm-prompt.blade.php b/resources/views/partials/confirm-prompt.blade.php index c519339..2b0af65 100644 --- a/resources/views/partials/confirm-prompt.blade.php +++ b/resources/views/partials/confirm-prompt.blade.php @@ -1,65 +1,213 @@ -
-
+{{-- + Ladill custom confirm dialog (replaces native window.confirm for app UX). -
+ Usage: + 1) Forms:
+ 2) JS: const ok = await window.ladillConfirm({ title, message, confirmLabel, variant }) + + Bottom sheet on mobile, centered card on desktop — same pattern as x-modal. +--}} +