feat: add confirmation prompts for activating contract and GDPR templates
This commit is contained in:
parent
19e6d34b1c
commit
35b0abd005
@ -160,6 +160,14 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (publish && type === 'contract') {
|
||||||
|
const kind = contractType === 'gdpr' ? 'GDPR' : 'Contract';
|
||||||
|
const ok = window.confirm(
|
||||||
|
`Activate this ${kind} template now?\n\nThis will deactivate other active ${kind} templates that apply to the same user type and language.`
|
||||||
|
);
|
||||||
|
if (!ok) return;
|
||||||
|
}
|
||||||
|
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
setStatusMsg(null);
|
setStatusMsg(null);
|
||||||
|
|
||||||
|
|||||||
@ -79,6 +79,19 @@ export default function ContractTemplateList({ refreshKey = 0, onEdit }: Props)
|
|||||||
|
|
||||||
const onToggleState = async (id: string, current: string) => {
|
const onToggleState = async (id: string, current: string) => {
|
||||||
const target = current === 'published' ? 'inactive' : 'active';
|
const target = current === 'published' ? 'inactive' : 'active';
|
||||||
|
|
||||||
|
// Confirmation: activating a contract/GDPR will deactivate other active templates of the same kind
|
||||||
|
if (target === 'active') {
|
||||||
|
const tpl = items.find((i) => i.id === id);
|
||||||
|
if (tpl?.type === 'contract') {
|
||||||
|
const kind = tpl.contract_type === 'gdpr' ? 'GDPR' : 'Contract';
|
||||||
|
const ok = window.confirm(
|
||||||
|
`Activate this ${kind} template now?\n\nThis will deactivate other active ${kind} templates that apply to the same user type and language.`
|
||||||
|
);
|
||||||
|
if (!ok) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const updated = await updateTemplateState(id, target as 'active' | 'inactive');
|
const updated = await updateTemplateState(id, target as 'active' | 'inactive');
|
||||||
setItems((prev) => prev.map((i) => i.id === id ? { ...i, status: updated.state === 'active' ? 'published' : 'draft' } : i));
|
setItems((prev) => prev.map((i) => i.id === id ? { ...i, status: updated.state === 'active' ? 'published' : 'draft' } : i));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user