From aee6639164a0fcebf1c126014852160e7ee758be Mon Sep 17 00:00:00 2001 From: isaacclad Date: Fri, 24 Jul 2026 20:56:17 +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 + resources/views/events/pro/index.blade.php | 2 +- .../views/partials/confirm-prompt.blade.php | 248 ++++++++++++++---- 6 files changed, 214 insertions(+), 52 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/events/pro/index.blade.php b/resources/views/events/pro/index.blade.php index 20bf93c..75ebd90 100644 --- a/resources/views/events/pro/index.blade.php +++ b/resources/views/events/pro/index.blade.php @@ -47,7 +47,7 @@ @endif @if ($subscription->auto_renew) -
+ @csrf
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. +--}} +