Commit bb11f974 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix(members): improve retroactive wizard error feedback and loading state

- Show loading spinner on submit button while saving
- Display error in a prominent red banner at top of wizard on failure
- Error message is now shown directly (not buried in generic alerts)
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent fd780847
...@@ -50,13 +50,8 @@ class RetroactiveWizardController extends Controller ...@@ -50,13 +50,8 @@ class RetroactiveWizardController extends Controller
if (!$result['success']) { if (!$result['success']) {
$errorMsg = $result['error'] ?? 'خطأ غير معروف'; $errorMsg = $result['error'] ?? 'خطأ غير معروف';
$errorLines = array_filter(explode("\n", $errorMsg));
$session = App::getInstance()->session(); $session = App::getInstance()->session();
$alerts = []; $session->flash('_wizard_error', $errorMsg);
foreach ($errorLines as $line) {
$alerts[] = ['type' => 'error', 'message' => trim($line)];
}
$session->flash('_alerts', $alerts);
$session->flash('_old_input', $_POST); $session->flash('_old_input', $_POST);
return $this->redirect('/members/retroactive-wizard'); return $this->redirect('/members/retroactive-wizard');
} }
......
...@@ -3,6 +3,19 @@ ...@@ -3,6 +3,19 @@
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<?php
$session = \App\Core\App::getInstance()->session();
$wizardAlerts = $session->getFlash('_wizard_error');
if ($wizardAlerts): ?>
<div style="background:#FEF2F2;border:2px solid #DC2626;border-radius:12px;padding:16px 20px;margin-bottom:16px;direction:rtl;">
<div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
<svg width="24" height="24" fill="none" stroke="#DC2626" stroke-width="2" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 8v4m0 4h.01"/></svg>
<strong style="color:#DC2626;font-size:15px;">حدث خطأ أثناء حفظ العضوية</strong>
</div>
<p style="color:#991B1B;margin:0;font-size:14px;"><?= e($wizardAlerts) ?></p>
</div>
<?php endif; ?>
<div id="retroWizard"> <div id="retroWizard">
<!-- Progress Bar --> <!-- Progress Bar -->
<div class="card" style="margin-bottom:16px;padding:16px;"> <div class="card" style="margin-bottom:16px;padding:16px;">
...@@ -1170,6 +1183,12 @@ document.getElementById('retroForm').addEventListener('submit', function(e) { ...@@ -1170,6 +1183,12 @@ document.getElementById('retroForm').addEventListener('submit', function(e) {
return; return;
} }
} }
// Show loading state
var btn = document.getElementById('btnSubmit');
btn.disabled = true;
btn.innerHTML = '<span class="spinner-border spinner-border-sm" role="status"></span> جاري الحفظ...';
btn.style.opacity = '0.7';
btn.style.cursor = 'not-allowed';
}); });
// Clear highlights on input // Clear highlights on input
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment