refactored confirmation dialogs to use a unified confirmAction modal
Some checks failed
PHPUnit / test (push) Has been cancelled
Some checks failed
PHPUnit / test (push) Has been cancelled
This commit is contained in:
@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user