From 1c42d3333c94f451f16a964c3a7c1897bcf6c98a Mon Sep 17 00:00:00 2001 From: caadiq Date: Sun, 4 Jan 2026 11:20:46 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=20=EB=B2=88=ED=98=B8=EB=A5=BC=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=EB=B3=84=EB=A1=9C=20=EB=B6=84=EB=A6=AC=20=EA=B3=84=EC=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컨셉 포토와 티저 각각 별도로 시작 번호 계산 - 타입 변경 시 해당 타입의 마지막 번호 +1로 자동 업데이트 - 업로드 후 수동 번호 증가 제거 (useEffect에서 자동 처리) --- .../src/pages/pc/admin/AdminAlbumPhotos.jsx | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/pc/admin/AdminAlbumPhotos.jsx b/frontend/src/pages/pc/admin/AdminAlbumPhotos.jsx index d97e67a..a6f9978 100644 --- a/frontend/src/pages/pc/admin/AdminAlbumPhotos.jsx +++ b/frontend/src/pages/pc/admin/AdminAlbumPhotos.jsx @@ -194,15 +194,17 @@ function AdminAlbumPhotos() { setTeasers(teasersData); } - // 시작 번호 자동 설정 (컨셉 포토와 티저 중 더 큰 값 + 1) + // 시작 번호 자동 설정 (현재 선택된 타입의 마지막 + 1) + // 컨셉 포토는 컨셉 포토끼리, 티저는 티저끼리 번호 계산 const maxPhotoOrder = photosData.length > 0 ? Math.max(...photosData.map(p => p.sort_order || 0)) : 0; const maxTeaserOrder = teasersData.length > 0 ? Math.max(...teasersData.map(t => t.sort_order || 0)) : 0; - const nextStartNumber = Math.max(maxPhotoOrder, maxTeaserOrder) + 1; - setStartNumber(nextStartNumber); + + // 기본값은 컨셉 포토 기준 + setStartNumber(maxPhotoOrder + 1); setLoading(false); } catch (error) { @@ -212,6 +214,21 @@ function AdminAlbumPhotos() { } }; + // 타입 변경 시 시작 번호 자동 업데이트 + useEffect(() => { + if (photoType === 'concept') { + const maxOrder = photos.length > 0 + ? Math.max(...photos.map(p => p.sort_order || 0)) + : 0; + setStartNumber(maxOrder + 1); + } else if (photoType === 'teaser') { + const maxOrder = teasers.length > 0 + ? Math.max(...teasers.map(t => t.sort_order || 0)) + : 0; + setStartNumber(maxOrder + 1); + } + }, [photoType, photos, teasers]); + const handleLogout = () => { localStorage.removeItem('adminToken'); localStorage.removeItem('adminUser'); @@ -463,10 +480,7 @@ function AdminAlbumPhotos() { if (result) { setToast({ message: result.message, type: 'success' }); - - // 다음 업로드를 위해 시작 번호를 마지막 파일 + 1로 설정 - const nextStartNumber = startNumber + pendingFiles.length; - setStartNumber(nextStartNumber); + // 시작 번호는 fetchAlbumData 후 useEffect에서 자동 업데이트됨 } // 미리보기 URL 해제