diff --git a/src/app/admin/contract-management/components/contractEditor.tsx b/src/app/admin/contract-management/components/contractEditor.tsx index 777f22d..1d57794 100644 --- a/src/app/admin/contract-management/components/contractEditor.tsx +++ b/src/app/admin/contract-management/components/contractEditor.tsx @@ -160,6 +160,14 @@ export default function ContractEditor({ onSaved, editingTemplateId, onCancelEdi 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); setStatusMsg(null); diff --git a/src/app/admin/contract-management/components/contractTemplateList.tsx b/src/app/admin/contract-management/components/contractTemplateList.tsx index 1b6d697..6aabfc0 100644 --- a/src/app/admin/contract-management/components/contractTemplateList.tsx +++ b/src/app/admin/contract-management/components/contractTemplateList.tsx @@ -79,6 +79,19 @@ export default function ContractTemplateList({ refreshKey = 0, onEdit }: Props) const onToggleState = async (id: string, current: string) => { 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 { 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));