fix: [demo] closeModal 등 함수를 window 스코프에 명시적 등록

This commit is contained in:
김보곤
2026-03-14 16:05:19 +09:00
parent 82fc2a45d6
commit d3ee183efc
2 changed files with 12 additions and 13 deletions

View File

@@ -95,24 +95,23 @@ class="refresh-btn inline-flex items-center gap-1.5 px-3 py-2 text-sm text-gray-
if (msg) showToast(msg);
});
function showDetailModal(id) {
const modal = document.getElementById('modal-container');
window.showDetailModal = function(id) {
htmx.ajax('GET', `/sales/demo-tenants/${id}`, {target: '#modal-container', swap: 'innerHTML'});
}
};
function closeModal() {
window.closeModal = function() {
document.getElementById('modal-container').innerHTML = '';
document.body.style.overflow = '';
}
};
function showToast(message, type) {
window.showToast = function(message, type) {
const toast = document.createElement('div');
const isError = type === 'error';
toast.className = `fixed top-4 right-4 z-[100] px-4 py-3 rounded-lg shadow-lg text-white text-sm font-medium transition-all transform ${isError ? 'bg-red-600' : 'bg-emerald-600'}`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => { toast.style.opacity = '0'; setTimeout(() => toast.remove(), 300); }, 3000);
}
};
// HX-Trigger 이벤트 파싱
document.body.addEventListener('htmx:afterRequest', function(e) {

View File

@@ -159,7 +159,7 @@ class="px-4 py-1.5 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-l
</div>
<script>
function extendDemo(id) {
window.extendDemo = function(id) {
if (!confirm('14일 연장하시겠습니까? (연장은 1회만 가능)')) return;
fetch(`/sales/demo-tenants/${id}/extend`, {
method: 'POST',
@@ -182,9 +182,9 @@ function extendDemo(id) {
}
})
.catch(() => showToast('오류가 발생했습니다.', 'error'));
}
};
function convertDemo(id) {
window.convertDemo = function(id) {
if (!confirm('정식 테넌트로 전환하시겠습니까?\n전환 후에는 데모 제한이 해제되고 되돌릴 수 없습니다.')) return;
fetch(`/sales/demo-tenants/${id}/convert`, {
method: 'POST',
@@ -205,9 +205,9 @@ function convertDemo(id) {
}
})
.catch(() => showToast('오류가 발생했습니다.', 'error'));
}
};
function deleteDemo(id, name) {
window.deleteDemo = function(id, name) {
if (!confirm(`"${name}" 데모 테넌트를 삭제하시겠습니까?\n데이터가 있는 테넌트는 삭제할 수 없습니다.`)) return;
fetch(`/sales/demo-tenants/${id}`, {
method: 'DELETE',
@@ -228,5 +228,5 @@ function deleteDemo(id, name) {
}
})
.catch(() => showToast('오류가 발생했습니다.', 'error'));
}
};
</script>