Skip to content

Commit

Permalink
Merge pull request TEAM-BEAT#434 from TEAM-BEAT/feat/TEAM-BEAT#433/bu…
Browse files Browse the repository at this point in the history
…ggix

[Bug/TEAM-BEAT#433] '공연 수정하기' 에서 cast 미리보기 안 뜨는 문제 + 추가된 회차에 예매한 경우 csv에 반영 안되는 문제
  • Loading branch information
ocahs9 authored Oct 22, 2024
2 parents 2edf1b4 + df1aed2 commit 0f2e17f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/apis/domains/performances/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useMakerPerformance = () => {
queryKey: [PERFORMANCE_QUERY_KEY.DETAIL],
queryFn: getMakerPerformance,
// staleTime: 1000 * 60 * 60,
gcTime: 1000 * 60 * 60 * 24,
gcTime: 0,
});
};

Expand Down
24 changes: 15 additions & 9 deletions src/pages/modifyManage/ModifyManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ const ModifyManage = () => {
castRole: item.castRole ?? "",
castPhoto: item.castPhoto ?? "",
}))
: [{ castId: -1, castName: "", castRole: "", castPhoto: "" }],
: [],
staffModifyRequests: data.staffList?.length
? data.staffList.map((item) => ({
staffId: item.staffId ?? -1,
staffName: item.staffName ?? "",
staffRole: item.staffRole ?? "",
staffPhoto: item.staffPhoto ?? "",
}))
: [{ staffId: -1, staffName: "", staffRole: "", staffPhoto: "" }],
: [],
bankName: data.bankName,
accountHolder: data.accountHolder,
performanceImageModifyRequests: data.performanceImageList?.length
Expand Down Expand Up @@ -305,6 +305,7 @@ const ModifyManage = () => {
//비즈니스 로직 분리 - 공연 수정하기 PUT 요청
const handleComplete = async () => {
const { data, isSuccess } = await refetch();
//presignedUrl로 받아온 데이터들을 저장할 변수
let posterUrls: string[];
let castUrls: string[];
let staffUrls: string[];
Expand All @@ -314,6 +315,7 @@ const ModifyManage = () => {
return;
} else if (isSuccess) {
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]);
Expand All @@ -322,8 +324,10 @@ const ModifyManage = () => {
return [...posterUrls, ...castUrls, ...staffUrls, ...performanceUrls];
};

//배열 형태로 추출된 모든 presignedUrls
const S3Urls = extractUrls(data);

//기존에 갖고 있던 이미지들의 주소들 -> files
const files = [
dataState.posterImage,
...dataState.castModifyRequests.map((cast) => cast.castPhoto),
Expand All @@ -336,10 +340,14 @@ const ModifyManage = () => {
S3Urls.map(async (url, index) => {
const file = files[index];

//여기 왜 fetch하는거지? 그냥 받아오면 안되는건가? -> blob 메서드를 사용하려면 response 타입이 필요하기 때문
const response = await fetch(file);

//blob타입으로 변환 과정
const blob = await response.blob();
const newFile = new File([blob], `fileName-${new Date()}`, { type: blob.type });

//새롭게 받은 url에 해당 파일 저장
return putS3({ url, file: newFile });
})
);
Expand Down Expand Up @@ -556,7 +564,7 @@ const ModifyManage = () => {
value={dataState.performanceTitle}
onChange={(e) => handleInputChange("performanceTitle", e.target.value)}
placeholder="등록될 공연의 이름을 입력해주세요."
maxLength={30}
maxLength={18}
cap={true}
/>
</InputModifyManageBox>
Expand Down Expand Up @@ -838,12 +846,10 @@ const ModifyManage = () => {
contact={dataState.performanceContact as string}
teamName={dataState.performanceTeamName as string}
castList={
dataState.castModifyRequests?.[0]?.castId === -1
? []
: (dataState.castModifyRequests?.map((cast, index) => ({
...cast,
//castId: index + 1,
})) as Cast[])
dataState.castModifyRequests?.map((cast, index) => ({
...cast,
//castId: index + 1,
})) as Cast[]
}
staffList={
dataState.staffModifyRequests?.map((cast, index) => ({
Expand Down
2 changes: 2 additions & 0 deletions src/pages/modifyManage/components/RoleLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const RoleLayout = ({ list, updateList, title }: RoleLayoutProps) => {
}))
);

//처음 딱 들어갔을 때 대기하고 있는 스태프, 캐스트에서는 isNew가 undefined임
//그리고 여전히 makerId : -1로 있음 (동일하게) -> 그래서 처음에 staff 추가누르면 엉뚱하게 사진은 cast에 추가되는 현상 발생
const handelAddRole = () => {
setMakerList((prev) => [
...prev,
Expand Down
1 change: 1 addition & 0 deletions src/pages/modifyManage/components/RoleWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const RoleWrapper = ({ id, role, removeRole, onUpdateRole }: RoleWrapperProps) =
setOpenImageModal(false); // 모달 닫기
};

//문제 가능성(원인)2 -> 처음 들어올 때는 항상 -1이고, x버튼 눌렀다가 +누르고 추가하면 newDate로 추가됨.
return (
<>
<S.RoleWrapper>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/ticketholderlist/TicketHolderList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,11 @@ const TicketHolderList = () => {
</S.FooterButtonText>
<S.MarginBottom $value="2.4rem">
<Button>
<CSVLink data={CSVDataArr} headers={headers} filename="예매자 목록.csv">
<CSVLink
data={CSVDataArr}
headers={headers}
filename={`${data.performanceTitle}_예매자 목록.csv`}
>
예매자 목록 다운받기
</CSVLink>
</Button>
Expand Down

0 comments on commit 0f2e17f

Please sign in to comment.