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,15 +1,20 @@
import { apiPatch } from './api.js';
import { showToast } from './app.js';
import { confirmAction } from './confirm-modal.js';
export function isClientArchived(c) {
return Number(c.archived) === 1;
}
export async function confirmAndPatchClientArchive(clientCode, archived) {
const msg = archived
? `Archive client "${clientCode}"? They will be hidden from assignments, follow-up, and the mobile app. You can restore them later from the Clients page.`
: `Restore client "${clientCode}" to active lists?`;
if (!confirm(msg)) return false;
if (!(await confirmAction({
title: archived ? 'Archive client' : 'Restore client',
message: archived
? `Archive client "${clientCode}"? They will be hidden from assignments, follow-up, and the mobile app. You can restore them later from the Clients page.`
: `Restore client "${clientCode}" to active lists?`,
confirmLabel: archived ? 'Archive' : 'Restore',
variant: archived ? 'danger' : 'default',
}))) return false;
try {
await apiPatch('clients.php', { clientCode, archived });