diff --git a/backend/templates/admin_product_images.html b/backend/templates/admin_product_images.html index e3abe8d..312e3e8 100644 --- a/backend/templates/admin_product_images.html +++ b/backend/templates/admin_product_images.html @@ -743,6 +743,13 @@ let replaceTargetBarcode = null; function openReplaceModal(barcode, productName) { + console.log('openReplaceModal called with:', barcode, productName); + + if (!barcode || barcode === 'null' || barcode === 'undefined') { + showToast('바코드 정보가 없습니다', 'error'); + return; + } + replaceTargetBarcode = barcode; document.getElementById('replaceProductName').textContent = productName || barcode; document.getElementById('replaceBarcode').textContent = barcode; @@ -769,11 +776,18 @@ return; } + // 바코드 검증 + if (!replaceTargetBarcode || replaceTargetBarcode === 'null' || replaceTargetBarcode === 'undefined') { + showToast('바코드 정보가 없습니다. 다시 시도해주세요.', 'error'); + return; + } + + const barcode = replaceTargetBarcode; closeReplaceModal(); - showToast('이미지 다운로드 중...', 'info'); + showToast(`"${barcode}" 이미지 다운로드 중...`, 'info'); try { - const res = await fetch(`/api/admin/product-images/${replaceTargetBarcode}/replace`, { + const res = await fetch(`/api/admin/product-images/${barcode}/replace`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ image_url: imageUrl })