Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat/#361] 공연 수정하기 Step2(스태프&캐스트 리스트) 수정 가능하도록 변경 + 상세 이미지 추가 및 변경 #379

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
09c961f
feat: step2(스태프리스트,캐스트리스트 수정) 부활
ocahs9 Aug 26, 2024
b755519
fix: 입력 가능하도록 변경, 삭제 버튼 활성화
ocahs9 Aug 26, 2024
6a04442
feat: 타입 최신화
ocahs9 Aug 26, 2024
8644f2a
fix: 바뀐 api 명세에 맞게 타입 선언, 함수 설정
ocahs9 Aug 26, 2024
2237165
fix: request 보낼 속성 이름으로 수정(코드 가독성 향상 목적)
ocahs9 Aug 26, 2024
f3742d7
fix: 좀 더 가독성 좋도록 makerId로 이름 통일
ocahs9 Aug 26, 2024
92b07ed
feat: 새롭게 추가된 maker(staff,cast)인지 판단하여 id 추가 여부를 결정하는 로직 구현
ocahs9 Aug 26, 2024
58fd1e6
fix: id가 없는 경우도 있을 것 같아서, 옵셔널로 변경
ocahs9 Aug 26, 2024
d403a2e
fix: map, every가 안되는 경우도 고려하여 ?. 연산자 사용
ocahs9 Aug 26, 2024
33c312d
fix: undefinde라 map을 사용할 수 없다는 문제 해결 - 받아오는 데이터 타입 제대로 설정
ocahs9 Aug 26, 2024
e4085bf
fix: 옵셔널에 .? 연산자를 안주어서 생긴 Cannot read properties of undefined 해결
ocahs9 Aug 26, 2024
5b60d0b
chore: 수정하기 요청 500에러 나는 이유 주석 기술
ocahs9 Aug 26, 2024
4d2ecde
fix: 총 회차 수 동적으로 조절
ocahs9 Aug 27, 2024
d7fcc5f
fix: api로 받아온 값 읽지 못하는 버그 수정
ocahs9 Aug 27, 2024
8c66b91
feat: 상세 이미지 타입 추가
ocahs9 Aug 28, 2024
f9c086f
Merge branch 'develop' into feat/#361/ModifyManageStep2
ocahs9 Aug 29, 2024
b2df460
fix: dataState가 잘 찼는지 확인하기 위해 type 일부 옵셔녈로 변경
ocahs9 Aug 29, 2024
ed25e81
fix: 상세이미지 수정 가능하도록 타입 정의, 컴포넌트 추가
ocahs9 Aug 29, 2024
8ed463a
fix: 잘못된 err 반환으로 인해 alert 안 뜨는 문제 수정
ocahs9 Aug 29, 2024
04b8f1c
fix: open-api 타입 최신화
ocahs9 Aug 29, 2024
b84274e
fix: 에러 객체를 정상적으로 받아 사용할 수 있도록 수정
ocahs9 Aug 29, 2024
e79c73f
Merge branch 'develop' into feat/#361/ModifyManageStep2
ocahs9 Aug 30, 2024
73bab41
상세 이미지까지 추가해서 공연 수정하기 api 구성
ocahs9 Aug 30, 2024
234d3ce
fix: 공연 수정하기 조회 api에서 상세 이미지 안 불러오던 버그 해결
ocahs9 Aug 30, 2024
d460dc0
fix: 공연 소개 500자로 변경
ocahs9 Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/apis/domains/performances/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export const getMakerPerformance = async (): Promise<MakerPerformanceResponse |
};

// 공연 수정 페이지 정보 조회 API (GET)
type PerformanceEditResponse = components["schemas"]["PerformanceEditResponse"];
type PerformanceModifyDetailResponse = components["schemas"]["PerformanceModifyDetailResponse"];

export const getPerformanceEdit = async (
performanceId: number
): Promise<PerformanceEditResponse | null> => {
): Promise<PerformanceModifyDetailResponse | null> => {
try {
const response: AxiosResponse<ApiResponseType<PerformanceEditResponse>> = await get(
const response: AxiosResponse<ApiResponseType<PerformanceModifyDetailResponse>> = await get(
`performances/${performanceId}`
);
return response.data.data;
Expand All @@ -47,7 +47,7 @@ export const deletePerformance = async (
return response.data.data;
} catch (error) {
console.log("error", error);
throw error;
throw new Error(error);
}
};

Expand Down Expand Up @@ -129,19 +129,18 @@ export const postPerformance = async (formData): Promise<PerformanceResponse | n
}
};

export type PerformanceUpdateResponse = components["schemas"]["PerformanceUpdateResponse"];
export type PerformanceModifyResponse = components["schemas"]["PerformanceModifyResponse"];

// 공연 수정 API (PUT)
export const updatePerformance = async (
formData
): Promise<PerformanceUpdateResponse | null | any> => {
): Promise<PerformanceModifyResponse | null | any> => {
try {
const response = await put("/performances", formData);

return response.data;
} catch (error) {
console.error("error", error);

return null;
throw error;
}
};
18 changes: 12 additions & 6 deletions src/apis/domains/performances/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { SHOW_TYPE_KEY } from "@pages/gig/constants";
import { BANK_TYPE, Cast, Staff } from "@pages/modifyManage/typings/gigInfo";
import {
BANK_TYPE,
Cast,
PerformanceImageModifyRequest,
Staff,
} from "@pages/modifyManage/typings/gigInfo";
import { QueryClient, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Dayjs } from "dayjs";
import { useNavigate } from "react-router-dom";
Expand Down Expand Up @@ -189,7 +194,6 @@ interface Schedule {

// gigInfo 타입 정의 예제
export interface PerformanceUpdateFormData {
accountHolder: string;
performanceId: number;
performanceTitle: string;
genre: SHOW_TYPE_KEY;
Expand All @@ -198,16 +202,18 @@ export interface PerformanceUpdateFormData {
performanceAttentionNote: string;
bankName: BANK_TYPE;
accountNumber: string;
accountHolder: string;
posterImage: string;
performanceTeamName: string;
performanceVenue: string;
performanceContact: string;
performancePeriod: string;
ticketPrice?: number | null;
totalScheduleCount: number;
scheduleList: Schedule[];
castList: Cast[];
staffList: Staff[];
ticketPrice?: number | null;
scheduleModifyRequests: Schedule[];
castModifyRequests: Cast[];
staffModifyRequests: Staff[];
performanceImageModifyRequests: PerformanceImageModifyRequest[];
}

export const useUpdatePerformance = () => {
Expand Down
60 changes: 34 additions & 26 deletions src/pages/modifyManage/ModifyMaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,77 @@ import RoleLayout from "./components/RoleLayout";
import * as S from "./ModifyManage.styled";
import { Cast, Staff } from "./typings/gigInfo";
interface ModifyManageMakerProps {
castList: Cast[];
staffList: Staff[];
castModifyRequests: Cast[];
staffModifyRequests: Staff[];
handleModifyManageStep: () => void;
updateGigInfo: (newInfo: Partial<{ castList: Cast[]; staffList: Staff[] }>) => void;
updateGigInfo: (
newInfo: Partial<{ castModifyRequests: Cast[]; staffModifyRequests: Staff[] }>
) => void;
}

const ModifyManageMaker = ({
castList: prevCastList,
staffList: prevStaffList,
castModifyRequests: prevcastModifyRequests,
staffModifyRequests: prevstaffModifyRequests,
handleModifyManageStep,
updateGigInfo,
}: ModifyManageMakerProps) => {
const [castList, setCastList] = useState<Cast[]>(prevCastList);
const [staffList, setStaffList] = useState<Staff[]>(prevStaffList);
const [castModifyRequests, setcastModifyRequests] = useState<Cast[]>(prevcastModifyRequests);
const [staffModifyRequests, setstaffModifyRequests] = useState<Staff[]>(prevstaffModifyRequests);

const [isButtonDisabled, setIsButtonDisabled] = useState(true);

useEffect(() => {
const allCastFieldsFilled = castList.every(
const allCastFieldsFilled = castModifyRequests.every(
(cast) => cast.castName && cast.castRole && cast.castPhoto
);

const allStaffFieldsFilled = staffList.every(
const allStaffFieldsFilled = staffModifyRequests.every(
(staff) => staff.staffName && staff.staffRole && staff.staffPhoto
);

setIsButtonDisabled(
!(
(castList?.length <= 1 &&
!castList[0]?.castName &&
!castList[0]?.castRole &&
!castList[0]?.castPhoto) ||
(castModifyRequests?.length <= 1 &&
!castModifyRequests[0]?.castName &&
!castModifyRequests[0]?.castRole &&
!castModifyRequests[0]?.castPhoto) ||
allCastFieldsFilled
) ||
!(
(castList?.length <= 1 &&
!staffList[0]?.staffName &&
!staffList[0]?.staffRole &&
!staffList[0]?.staffPhoto) ||
(castModifyRequests?.length <= 1 &&
!staffModifyRequests[0]?.staffName &&
!staffModifyRequests[0]?.staffRole &&
!staffModifyRequests[0]?.staffPhoto) ||
allStaffFieldsFilled
)
);
}, [castList, staffList]);
}, [castModifyRequests, staffModifyRequests]);

const handleUpdateList = (title: string, updatedList: Cast[] | Staff[]) => {
if (title === "출연진") {
setCastList(updatedList as Cast[]);
setcastModifyRequests(updatedList as Cast[]);
} else if (title === "스태프") {
setStaffList(updatedList as Staff[]);
setstaffModifyRequests(updatedList as Staff[]);
}
updateGigInfo({ castList, staffList });
updateGigInfo({
castModifyRequests: castModifyRequests,
staffModifyRequests: staffModifyRequests,
});
};

const handleList = () => {
// 모든 속성이 비어있는 객체들 필터링
const filteredCastList = castList.filter(
const filteredcastModifyRequests = castModifyRequests.filter(
(cast) => cast.castName || cast.castRole || cast.castPhoto
);
const filteredStaffList = staffList.filter(
const filteredstaffModifyRequests = staffModifyRequests.filter(
(staff) => staff.staffName || staff.staffRole || staff.staffPhoto
);

updateGigInfo({ castList: filteredCastList, staffList: filteredStaffList });
updateGigInfo({
castModifyRequests: filteredcastModifyRequests,
staffModifyRequests: filteredstaffModifyRequests,
});
handleModifyManageStep();
};

Expand All @@ -75,13 +83,13 @@ const ModifyManageMaker = ({
<S.ModifyManageContainer>
<RoleLayout
title="출연진"
list={castList}
list={castModifyRequests}
updateList={(list) => handleUpdateList("출연진", list)}
/>
<S.Divider />
<RoleLayout
title="스태프"
list={staffList}
list={staffModifyRequests}
updateList={(list) => handleUpdateList("스태프", list)}
/>
</S.ModifyManageContainer>
Expand Down
23 changes: 23 additions & 0 deletions src/pages/modifyManage/ModifyManage.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ export const FileInputWrapper = styled.div`
gap: 1.4rem;
`;

export const FilesInputWrapper = styled.div`
position: relative;

${Generators.flexGenerator("row", "center", "start")}
gap: 1.4rem;
width: calc(100% + 2.4rem);
padding-right: 2.4rem;
overflow-x: scroll;

&::-webkit-scrollbar {
display: none;
}
`;

export const HiddenFileInput = styled.input`
display: none;
`;
Expand All @@ -135,6 +149,15 @@ export const CustomFileInput = styled.label<{ width?: number; height?: number }>
border-radius: 6px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2) 여기 CustomFileInput에 flex-shrink: 0추가해주세요!
image
스크롤 넘어가면 깨지고 있어요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 반영하겠습니다!

`;

export const CustomFileInputCounter = styled.p`
color: ${({ theme }) => theme.colors.gray_500};
${({ theme }) => theme.fonts["body1-normal-medi"]};
`;

export const CustomFileInputLength = styled.span`
color: ${({ theme }) => theme.colors.white};
`;

export const PreviewImageWrapper = styled.article<{ width?: number; height?: number }>`
position: relative;
width: ${({ width }) => (width ? width : 10.8)}rem;
Comment on lines 161 to 163
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2) 여기 PreviewImageWrapper에도 flex-shrink: 0; 추가해주세요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 반영하겠습니다!

Expand Down
Loading
Loading