Repository navigation
[Refactor/#521] 전체 이미지 presigned 업로드 계약 동기화 - #523
Conversation
Summary by CodeRabbit
Walkthrough공연 등록·수정과 관리자 캐러셀의 이미지 업로드가 uploadUrl 직접 사용 및 imageKey 전달 방식으로 변경되었습니다. Presigned 응답 타입이 갱신되었고, 파일명 기반 매핑과 업로드 실패 처리가 적용되었습니다. Changes이미지 업로드 계약
공연 이미지 흐름
관리자 캐러셀
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant RegisterPage
participant PresignedAPI
participant S3Uploader
participant BackendAPI
RegisterPage->>PresignedAPI: 파일명별 업로드 정보 요청
PresignedAPI-->>RegisterPage: uploadUrl과 imageKey 반환
RegisterPage->>S3Uploader: 파일과 uploadUrl 전달
S3Uploader-->>RegisterPage: 업로드 완료
RegisterPage->>BackendAPI: imageKey 기반 등록·수정 요청
Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
PR 작성하느라 고생 많았어요!! 라벨 잘 지정되었는지 확인 한 번 해 주기 🫶 |
sinji2102
left a comment
There was a problem hiding this comment.
수정사항만 확인해 주면 머지해도 될 것 같아용
굿굿
Co-authored-by: Sinji Yun <66528589+sinji2102@users.noreply.github.com>
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/apis/domains/files/api.ts (1)
138-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win의미 없는
try/catch입니다.
catch (error) { throw error; }는 아무 동작도 하지 않으므로no-useless-catch대상입니다. try 블록을 제거하는 편이 깔끔합니다.♻️ 제안 리팩토링
- return response.data; - } catch (error) { - throw error; - } -}; + return response.data; +};(try 블록 시작부의
try {도 함께 제거하고 들여쓰기를 정리해 주세요.)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/apis/domains/files/api.ts` around lines 138 - 140, Remove the redundant try/catch surrounding the affected logic in the file API handler, including the try opening and catch block, then normalize indentation while preserving the existing statements and error propagation behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsx`:
- Around line 30-34: Update the saveCarouselNum call in AdminCarousel so the
optional promotionList is defaulted to an empty array before invoking map.
Preserve the existing promotionId extraction and ensure both missing data and
missing promotionList produce [] without throwing.
In `@src/admin/pages/promotion/Promotion.tsx`:
- Around line 117-136: Handle the empty formData.carousels case in the save flow
so deleting all carousels produces an explicit outcome. Update the condition
around updateCarousel and validation to either allow saving the empty list and
show the existing completion alert, or show a clear minimum-one-carousel alert;
ensure the empty list does not fall through to a no-op forEach.
In `@src/apis/domains/files/api.ts`:
- Around line 9-25: Update the ImagePresignedUpload interface so uploadUrl and
imageKey are optional, matching the generated schema contract. Then update each
call site using ImagePresignedUpload to validate both values before initiating
the S3 PUT, including cases where the upload object exists but either field is
missing.
---
Nitpick comments:
In `@src/apis/domains/files/api.ts`:
- Around line 138-140: Remove the redundant try/catch surrounding the affected
logic in the file API handler, including the try opening and catch block, then
normalize indentation while preserving the existing statements and error
propagation behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4b6da118-ddf2-4c8e-8c1b-d7ec7918b679
📒 Files selected for processing (7)
src/admin/pages/promotion/Promotion.tsxsrc/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsxsrc/apis/domains/files/api.tssrc/apis/domains/register/index.tssrc/pages/modifyManage/ModifyManage.tsxsrc/pages/register/Register.tsxsrc/typings/api/schema/index.ts
💤 Files with no reviewable changes (1)
- src/apis/domains/register/index.ts
| saveCarouselNum( | ||
| data?.promotionList.map((item) => { | ||
| return item.promotionId; | ||
| }) | ||
| }) ?? [] | ||
| ); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
promotionList가 없는 응답에서 .map 호출로 터집니다.
옵셔널 체이닝이 data?.promotionList까지만 적용되어 있어, data는 있고 promotionList가 undefined인 경우 .map에서 TypeError가 납니다(HomeFindAllResponse.promotionList는 스키마상 optional). ?? []는 이 경우를 막지 못합니다.
🐛 제안 수정
saveCarouselNum(
- data?.promotionList.map((item) => {
+ data?.promotionList?.map((item) => {
return item.promotionId;
}) ?? []
);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| saveCarouselNum( | |
| data?.promotionList.map((item) => { | |
| return item.promotionId; | |
| }) | |
| }) ?? [] | |
| ); | |
| saveCarouselNum( | |
| data?.promotionList?.map((item) => { | |
| return item.promotionId; | |
| }) ?? [] | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/admin/pages/promotion/components/AdminCarousel/AdminCarousel.tsx` around
lines 30 - 34, Update the saveCarouselNum call in AdminCarousel so the optional
promotionList is defaulted to an empty array before invoking map. Preserve the
existing promotionId extraction and ensure both missing data and missing
promotionList produce [] without throwing.
| if (allValid && formData.carousels.length !== 0) { | ||
| await updateCarousel(formData); | ||
|
|
||
| console.log(formData); | ||
|
|
||
| if (allValid && formData.carousels.length !== 0) { | ||
| const res = await updateCarousel(formData); | ||
| console.log(res); | ||
| await console.log(formData); | ||
|
|
||
| await openAlert({ | ||
| title: "캐러셀 수정이 완료되었습니다.", | ||
| okCallback: () => { | ||
| location.reload(); | ||
| }, | ||
| }); | ||
| } else { | ||
| formData.carousels.forEach((item) => { | ||
| if (!item.newImageUrl && !item.redirectUrl) { | ||
| openAlert({ title: "정보가 없는 캐러셀은 삭제해 주세요." }); | ||
| } else if (!item.newImageUrl) { | ||
| openAlert({ title: "모든 이미지를 삽입해 주세요." }); | ||
| } else if (!item.redirectUrl) { | ||
| openAlert({ title: "모든 링크를 삽입해 주세요." }); | ||
| } | ||
| }); | ||
| } | ||
| } catch (err) { | ||
| console.error("Error during file upload or carousel update:", err); | ||
| openAlert({ title: "캐러셀 수정 혹은 이미지 저장을 실패했습니다.\n 다시 시도해주세요." }); | ||
| await openAlert({ | ||
| title: "캐러셀 수정이 완료되었습니다.", | ||
| okCallback: () => { | ||
| location.reload(); | ||
| }, | ||
| }); | ||
| } else { | ||
| formData.carousels.forEach((item) => { | ||
| if (!item.newImageUrl && !item.redirectUrl) { | ||
| openAlert({ title: "정보가 없는 캐러셀은 삭제해 주세요." }); | ||
| } else if (!item.newImageUrl) { | ||
| openAlert({ title: "모든 이미지를 삽입해 주세요." }); | ||
| } else if (!item.redirectUrl) { | ||
| openAlert({ title: "모든 링크를 삽입해 주세요." }); | ||
| } | ||
| }); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
캐러셀을 전부 삭제한 뒤 저장하면 아무 반응이 없습니다.
formData.carousels.length === 0이면 updateCarousel도 호출되지 않고 else 분기의 forEach도 순회 대상이 없어 알림이 뜨지 않습니다. 사용자는 저장이 됐는지 알 수 없습니다. 빈 목록에 대한 처리(전체 삭제 저장을 허용하거나, 최소 1개 필요 안내)를 추가해 주세요.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/admin/pages/promotion/Promotion.tsx` around lines 117 - 136, Handle the
empty formData.carousels case in the save flow so deleting all carousels
produces an explicit outcome. Update the condition around updateCarousel and
validation to either allow saving the empty list and show the existing
completion alert, or show a clear minimum-one-carousel alert; ensure the empty
list does not fall through to a no-op forEach.
| poster: Record<string, ImagePresignedUpload>; | ||
| cast: Record<string, ImagePresignedUpload>; | ||
| staff: Record<string, ImagePresignedUpload>; | ||
| performance: Record<string, ImagePresignedUpload>; | ||
| } | ||
|
|
||
| export interface ImagePresignedUpload { | ||
| uploadUrl: string; | ||
| imageKey: string; | ||
| } | ||
|
|
||
| export interface PresignedAllResponse { | ||
| status: number; | ||
| message: string; | ||
| data: { | ||
| performanceMakerPresignedUrls: PresignedResponse; | ||
| performanceMakerPresignedUrls: Record<string, ImageInterface>; | ||
| performanceMakerPresignedUploads: PresignedResponse; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 스키마 정의와 수동 타입 선언 비교
rg -n -A4 'ImagePresignedUpload:|CarouselPresignedUploadResponse:|BannerPresignedUploadResponse:' src/typings/api/schema/index.ts
rg -n -B2 -A6 'interface ImagePresignedUpload' src
# uploadUrl 사용처
rg -n '\.uploadUrl' srcRepository: TEAM-BEAT/BEAT-Client
Length of output: 1813
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- src/apis/domains/files/api.ts lines 1-120 ---\n'
sed -n '1,120p' src/apis/domains/files/api.ts
printf '\n--- src/apis/domains/files/api.ts usages around presigned all response ---\n'
rg -n -B5 -A25 'PresignedAllResponse|getPresignedA|presigned|upload.*ImagePresignedUpload|data:.*ImagePresignedUpload' src/apis/domains/files/api.ts
printf '\n--- Register.tsx upload checks and calls ---\n'
sed -n '160,270p' src/pages/register/Register.tsx
printf '\n--- ModifyManage.tsx upload checks and calls ---\n'
sed -n '320,365p' src/pages/modifyManage/ModifyManage.tsx
printf '\n--- Promotion.tsx upload checks and calls ---\n'
sed -n '60,90p' src/admin/pages/promotion/Promotion.tsxRepository: TEAM-BEAT/BEAT-Client
Length of output: 250
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- src/apis/domains/files/api.ts lines 1-120 ---\n'
sed -n '1,120p' src/apis/domains/files/api.ts
printf '\n--- src/apis/domains/files/api.ts usages around presigned all response ---\n'
rg -n -B5 -A25 'PresignedAllResponse|getPresignedA|presigned|upload.*ImagePresignedUpload|data:.*ImagePresignedUpload' src/apis/domains/files/api.ts
printf '\n--- Register.tsxo upload checks and calls ---\n'
sed -n '160,270p' src/pages/register/Register.tsx
printf '\n--- ModifyManage.tsx upload checks and calls ---\n'
sed -n '320,365p' src/pages/modifyManage/ModifyManage.tsx
printf '\n--- Promotion.tsx upload checks and calls ---\n'
sed -n '60,90p' src/admin/pages/promotion/Promotion.tsxRepository: TEAM-BEAT/BEAT-Client
Length of output: 250
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- src/apis/domains/files/api.ts lines 1-120 ---'
sed -n '1,120p' src/apis/domains/files/api.ts
echo
echo '--- src/apis/domains/files/api.ts usages around presigned all response ---'
rg -n -B5 -A25 'PresignedAllResponse|getPresignedA|presigned|upload.*ImagePresignedUpload|data:.*ImagePresignedUpload' src/apis/domains/files/api.ts
echo
echo '--- Register.tsx upload checks and calls ---'
sed -n '160,270p' src/pages/register/Register.tsx
echo
echo '--- ModifyManage.tsx upload checks and calls ---'
sed -n '320,365p' src/pages/modifyManage/ModifyManage.tsx
echo
echo '--- Promotion.tsx upload checks and calls ---'
sed -n '60,90p' src/admin/pages/promotion/Promotion.tsxRepository: TEAM-BEAT/BEAT-Client
Length of output: 12733
ImagePresignedUpload 필드는 optional로 맞춰 타입 계약을 맞춰주세요.
src/typings/api/schema/index.ts의 생성 스키마는 uploadUrl?: string; imageKey?: string;, 그리고 캐러셀 스키마도 동일합니다. 현재 필수 필드 선언은 실제 응답과 불일치하며, !upload 체크는 존재하는 객체의 uploadUrl/imageKey 누락을 걸지 못합니다. 필드를 optional로 두고 각 호출부에서 값을 검증한 뒤 S3 PUT을 진행하면 안전합니다.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/apis/domains/files/api.ts` around lines 9 - 25, Update the
ImagePresignedUpload interface so uploadUrl and imageKey are optional, matching
the generated schema contract. Then update each call site using
ImagePresignedUpload to validate both values before initiating the S3 PUT,
including cases where the upload object exists but either field is missing.
|
멋지네요 |



📌 관련 이슈번호
🎟️ PR 유형
✅ Key Changes
uploadUrl과imageKey계약을 사용합니다.uploadUrl원문을 사용하고mutateAsync로 완료를 기다립니다.imageKey를 전달합니다./api/image/upload클라이언트 코드를 제거했습니다.🧪 검증
yarn prettier --check src/apis/domains/files/api.ts src/pages/register/Register.tsx src/pages/modifyManage/ModifyManage.tsx src/typings/api/schema/index.tsyarn tsc -bconsole경고 5건generatePerformanceRoute.test.ts기대 경로/gig/7불일치 2건과 ESLint 9에서 제거된--ext옵션 때문에 별도로 실패합니다. 이번 변경 파일과 무관합니다.📢 To Reviewers
📸 스크린샷
🔗 참고 자료