Skip to content

Commit

Permalink
feat: 공연진 이미지 선택으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
imddoy committed Dec 3, 2024
1 parent 8b85e37 commit 7ada53d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/pages/gig/components/peopleCard/PeopleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface PeopleCardProps {
const PeopleCard = ({ photo, role, name }: PeopleCardProps) => {
return (
<S.PeopleCardContainer>
<S.PeopleCardPhoto src={photo} />
{photo && <S.PeopleCardPhoto src={photo} />}
<S.PeopleCardTextBox>
<S.PeopleCardRole>{role}</S.PeopleCardRole>
<S.PeopleCardName>{name}</S.PeopleCardName>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/modifyManage/ModifyMaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
23 changes: 16 additions & 7 deletions src/pages/modifyManage/ModifyManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
];

Expand Down Expand Up @@ -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 안보내야 함)
Expand All @@ -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 안보내야 함)
Expand Down
19 changes: 12 additions & 7 deletions src/pages/register/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];

Expand All @@ -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();
Expand Down
8 changes: 2 additions & 6 deletions src/pages/register/RegisterMaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
!(
Expand Down

0 comments on commit 7ada53d

Please sign in to comment.