diff --git a/backend/templates/admin_otc_labels.html b/backend/templates/admin_otc_labels.html
index a0c32b1..cbef6bb 100644
--- a/backend/templates/admin_otc_labels.html
+++ b/backend/templates/admin_otc_labels.html
@@ -191,6 +191,11 @@
color: white;
}
.btn-print:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
+ .btn-delete {
+ background: #fee2e2;
+ color: #dc2626;
+ }
+ .btn-delete:hover { background: #fecaca; }
/* 미리보기 */
.preview-container {
@@ -334,6 +339,7 @@
+
@@ -503,21 +509,27 @@
usage_tip: document.getElementById('usageTip').value
};
+ console.log('저장 payload:', payload);
+
try {
const res = await fetch('/api/admin/otc-labels', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
+
+ console.log('저장 응답 status:', res.status);
const data = await res.json();
+ console.log('저장 응답 data:', data);
if (data.success) {
showToast('저장 완료!', 'success');
loadLabelList();
} else {
- showToast(data.error, 'error');
+ showToast(data.error || '알 수 없는 오류', 'error');
}
} catch (err) {
+ console.error('저장 오류:', err);
showToast('저장 오류: ' + err.message, 'error');
}
}
@@ -559,6 +571,43 @@
}
}
+ // 삭제
+ async function deleteLabel() {
+ if (!currentBarcode) {
+ showToast('삭제할 프리셋이 없습니다', 'error');
+ return;
+ }
+
+ if (!confirm(`"${currentDrugName}" 프리셋을 삭제하시겠습니까?`)) {
+ return;
+ }
+
+ try {
+ const res = await fetch(`/api/admin/otc-labels/${currentBarcode}`, {
+ method: 'DELETE'
+ });
+ const data = await res.json();
+
+ if (data.success) {
+ showToast('삭제 완료!', 'success');
+ // 폼 초기화
+ currentBarcode = '';
+ currentDrugName = '';
+ document.getElementById('barcode').value = '';
+ document.getElementById('displayName').value = '';
+ document.getElementById('effect').value = '';
+ document.getElementById('dosageInstruction').value = '';
+ document.getElementById('usageTip').value = '';
+ document.getElementById('previewContainer').innerHTML = '미리보기를 클릭하면 라벨이 표시됩니다
';
+ loadLabelList();
+ } else {
+ showToast(data.error || '삭제 실패', 'error');
+ }
+ } catch (err) {
+ showToast('삭제 오류: ' + err.message, 'error');
+ }
+ }
+
// 목록 로드
async function loadLabelList() {
try {