refactored confirmation dialogs to use a unified confirmAction modal
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-06-14 18:02:03 +02:00
parent 6ae29f1648
commit b06c4bf3ee
10 changed files with 295 additions and 39 deletions

View File

@ -1,5 +1,6 @@
import { apiGet, apiPost, apiPut, apiDelete } from '../api.js';
import { getRole, getUser, pageHeaderHTML, showToast } from '../app.js';
import { confirmAction } from '../confirm-modal.js';
import { openAdminResetPasswordModal } from '../password-modal.js';
// Roles an admin can create; supervisors can only create coaches
@ -319,10 +320,12 @@ async function reassignCoachSupervisor(selectEl) {
}
async function revokeUserSessions(userID, username) {
if (!confirm(
`Sign out "${username}" on all devices?\n\n`
+ 'They must log in again on the website and mobile app.'
)) {
if (!(await confirmAction({
title: 'Sign out everywhere',
message: `Sign out "${username}" on all devices?\n\nThey must log in again on the website and mobile app.`,
confirmLabel: 'Sign out',
variant: 'danger',
}))) {
return;
}
try {
@ -336,7 +339,12 @@ async function revokeUserSessions(userID, username) {
}
async function deleteUser(userID, username) {
if (!confirm(`Delete user "${username}"? This cannot be undone.`)) return;
if (!(await confirmAction({
title: 'Delete user',
message: `Delete user "${username}"? This cannot be undone.`,
confirmLabel: 'Delete',
variant: 'danger',
}))) return;
try {
const data = await apiDelete('users.php', { userID });
if (data.success) {