fix: 이미지 교체 시 바코드 검증 강화

- openReplaceModal에서 바코드 유효성 검사
- submitReplace에서 null/undefined 바코드 차단
- 디버깅 로그 추가
This commit is contained in:
thug0bin 2026-03-02 23:52:31 +09:00
parent 4a3ec38ba7
commit 65754f594b

View File

@ -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 })