fix family card issue
This commit is contained in:
@@ -614,12 +614,26 @@
|
||||
const m = ensureModal();
|
||||
if (m) m.show();
|
||||
} catch (e) {
|
||||
// Fallback: redirect to /family filtered page
|
||||
try {
|
||||
const gid = params && params.guardian_id;
|
||||
const sid = params && params.student_id;
|
||||
if (gid) window.location.href = '<?= site_url('family') ?>' + '?guardian_id=' + encodeURIComponent(gid);
|
||||
else if (sid) window.location.href = '<?= site_url('family') ?>' + '?student_id=' + encodeURIComponent(sid);
|
||||
const familyUrl = new URL('<?= site_url('family') ?>', window.location.origin);
|
||||
const currentPath = window.location.pathname.replace(/\/+$/, '');
|
||||
const familyPath = familyUrl.pathname.replace(/\/+$/, '');
|
||||
const familyIndexPath = familyPath + '/index';
|
||||
|
||||
// A failed card request used to redirect the family page back to
|
||||
// itself. Its automatic card loader then repeated that forever.
|
||||
if (currentPath !== familyPath && currentPath !== familyIndexPath && (gid || sid)) {
|
||||
familyUrl.searchParams.set(gid ? 'guardian_id' : 'student_id', gid || sid);
|
||||
window.location.href = familyUrl.toString();
|
||||
return;
|
||||
}
|
||||
|
||||
const target = document.getElementById('familyCardContent');
|
||||
if (target) target.innerHTML = '<div class="p-3 text-danger">The family card could not be loaded. Please refresh and try again.</div>';
|
||||
const m = ensureModal();
|
||||
if (m) m.show();
|
||||
} catch(_) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user