From 7ada53d8974108c71de746a6a47ed249c9d3b042 Mon Sep 17 00:00:00 2001 From: imddoy Date: Wed, 4 Dec 2024 06:57:50 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B3=B5=EC=97=B0=EC=A7=84=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=84=A0=ED=83=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gig/components/peopleCard/PeopleCard.tsx | 2 +- src/pages/modifyManage/ModifyMaker.tsx | 4 ++-- src/pages/modifyManage/ModifyManage.tsx | 23 +++++++++++++------ src/pages/register/Register.tsx | 19 +++++++++------ src/pages/register/RegisterMaker.tsx | 8 ++----- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/pages/gig/components/peopleCard/PeopleCard.tsx b/src/pages/gig/components/peopleCard/PeopleCard.tsx index e5cb0691..42060668 100644 --- a/src/pages/gig/components/peopleCard/PeopleCard.tsx +++ b/src/pages/gig/components/peopleCard/PeopleCard.tsx @@ -9,7 +9,7 @@ interface PeopleCardProps { const PeopleCard = ({ photo, role, name }: PeopleCardProps) => { return ( - + {photo && } {role} {name} diff --git a/src/pages/modifyManage/ModifyMaker.tsx b/src/pages/modifyManage/ModifyMaker.tsx index d3b3bb31..04bcf084 100644 --- a/src/pages/modifyManage/ModifyMaker.tsx +++ b/src/pages/modifyManage/ModifyMaker.tsx @@ -25,11 +25,11 @@ const ModifyManageMaker = ({ useEffect(() => { const allCastFieldsFilled = castModifyRequests.every( - (cast) => cast.castName && cast.castRole && cast.castPhoto + (cast) => cast.castName && cast.castRole ); const allStaffFieldsFilled = staffModifyRequests.every( - (staff) => staff.staffName && staff.staffRole && staff.staffPhoto + (staff) => staff.staffName && staff.staffRole ); setIsButtonDisabled( diff --git a/src/pages/modifyManage/ModifyManage.tsx b/src/pages/modifyManage/ModifyManage.tsx index a6ee46a0..31822a40 100644 --- a/src/pages/modifyManage/ModifyManage.tsx +++ b/src/pages/modifyManage/ModifyManage.tsx @@ -333,11 +333,16 @@ const ModifyManage = () => { const extractUrls = (data: PresignedResponse) => { //앞부분(유효한 부분)만 떼어내서 저장(뒷 부분은 사진이 뜨는 url이 아님) posterUrls = Object.values(data.poster).map((url) => url.split("?")[0]); - castUrls = Object.values(data.cast).map((url) => url.split("?")[0]); - staffUrls = Object.values(data.staff).map((url) => url.split("?")[0]); + castUrls = Object.values(data.cast).map((url) => (url !== "" ? url.split("?")[0] : null)); + staffUrls = Object.values(data.staff).map((url) => (url !== "" ? url.split("?")[0] : null)); performanceUrls = Object.values(data.performance).map((url) => url.split("?")[0]); - return [...posterUrls, ...castUrls, ...staffUrls, ...performanceUrls]; + return [ + ...posterUrls, + ...castUrls.filter((url) => url !== null), + ...staffUrls.filter((url) => url !== null), + ...performanceUrls, + ]; }; //배열 형태로 추출된 모든 presignedUrls @@ -346,8 +351,12 @@ const ModifyManage = () => { //기존에 갖고 있던 이미지들의 주소들 -> files const files = [ dataState.posterImage, - ...dataState.castModifyRequests.map((cast) => cast.castPhoto), - ...dataState.staffModifyRequests.map((staff) => staff.staffPhoto), + ...dataState.castModifyRequests + .map((cast) => cast.castPhoto) + .filter((photo) => photo !== ""), + ...dataState.staffModifyRequests + .map((staff) => staff.staffPhoto) + .filter((photo) => photo !== ""), ...dataState.performanceImageModifyRequests.map((obj) => obj.performanceImage), ]; @@ -400,7 +409,7 @@ const ModifyManage = () => { castModifyRequests: dataState.castModifyRequests.map((cast, index) => { const modifiedCast = { ...cast, - castPhoto: castUrls[index] || cast.castPhoto, + castPhoto: cast.castPhoto === "" ? "" : castUrls[index] || cast.castPhoto, }; if (modifiedCast.castId === -1) { delete modifiedCast.castId; // castId가 -1인 경우 castId를 삭제(새롭게 추가된 경우에는 id 안보내야 함) @@ -410,7 +419,7 @@ const ModifyManage = () => { staffModifyRequests: dataState.staffModifyRequests.map((staff, index) => { const modifiedStaff = { ...staff, - staffPhoto: staffUrls[index] || staff.staffPhoto, + staffPhoto: staff.staffPhoto === "" ? "" : staffUrls[index] || staff.staffPhoto, }; if (modifiedStaff.staffId === -1) { delete modifiedStaff.staffId; // staffId가 -1인 경우 staffId를 삭제(새롭게 추가된 경우에는 id 안보내야 함) diff --git a/src/pages/register/Register.tsx b/src/pages/register/Register.tsx index 58ae1e93..49f88276 100644 --- a/src/pages/register/Register.tsx +++ b/src/pages/register/Register.tsx @@ -195,18 +195,23 @@ const Register = () => { if (isSuccess) { const extractUrls = (data: PresignedResponse) => { posterUrls = Object.values(data.poster).map((url) => url.split("?")[0]); - castUrls = Object.values(data.cast).map((url) => url.split("?")[0]); - staffUrls = Object.values(data.staff).map((url) => url.split("?")[0]); + castUrls = Object.values(data.cast).map((url) => (url !== "" ? url.split("?")[0] : null)); + staffUrls = Object.values(data.staff).map((url) => (url !== "" ? url.split("?")[0] : null)); performanceUrls = Object.values(data.performance).map((url) => url.split("?")[0]); - return [...posterUrls, ...castUrls, ...staffUrls, ...performanceUrls]; + return [ + ...posterUrls, + ...castUrls.filter((url) => url !== null), + ...staffUrls.filter((url) => url !== null), + ...performanceUrls, + ]; }; const S3Urls = extractUrls(data); const files = [ gigInfo.posterImage, - ...gigInfo.castList.map((cast) => cast.castPhoto), - ...gigInfo.staffList.map((staff) => staff.staffPhoto), + ...gigInfo.castList.map((cast) => cast.castPhoto).filter((photo) => photo !== ""), + ...gigInfo.staffList.map((staff) => staff.staffPhoto).filter((photo) => photo !== ""), ...gigInfo.performanceImageList.map((image) => image.performanceImage), ]; @@ -228,11 +233,11 @@ const Register = () => { posterImage: posterUrls[0], castList: gigInfo.castList.map((cast, index) => ({ ...cast, - castPhoto: castUrls[index] || cast.castPhoto, + castPhoto: cast.castPhoto === "" ? "" : castUrls[index] || cast.castPhoto, })), staffList: gigInfo.staffList.map((staff, index) => ({ ...staff, - staffPhoto: staffUrls[index] || staff.staffPhoto, + staffPhoto: staff.staffPhoto === "" ? "" : staffUrls[index] || staff.staffPhoto, })), scheduleList: gigInfo.scheduleList.map((schedule) => { const date = dayjs(schedule.performanceDate).toDate(); diff --git a/src/pages/register/RegisterMaker.tsx b/src/pages/register/RegisterMaker.tsx index c76a7055..3a73c0ba 100644 --- a/src/pages/register/RegisterMaker.tsx +++ b/src/pages/register/RegisterMaker.tsx @@ -24,13 +24,9 @@ const RegisterMaker = ({ const [isButtonDisabled, setIsButtonDisabled] = useState(true); useEffect(() => { - const allCastFieldsFilled = castList.every( - (cast) => cast.castName && cast.castRole && cast.castPhoto - ); + const allCastFieldsFilled = castList.every((cast) => cast.castName && cast.castRole); - const allStaffFieldsFilled = staffList.every( - (staff) => staff.staffName && staff.staffRole && staff.staffPhoto - ); + const allStaffFieldsFilled = staffList.every((staff) => staff.staffName && staff.staffRole); setIsButtonDisabled( !(