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

게시글 수정 api 변경에 따른 적용_Feat/#145 #147

Merged
merged 7 commits into from
Jul 27, 2023
11 changes: 8 additions & 3 deletions frontend/src/components/PostForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps
endTime: deadline,
voteInfo,
} = data ?? {};
const options = voteInfo?.options ?? [];

const navigate = useNavigate();

Expand Down Expand Up @@ -84,14 +85,18 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps

imageFileList.map(file => formData.append('images', file));

const optionTextAreas = e.target.querySelectorAll('textarea[name="optionText"]');
const writingOptionTexts = Array.from(optionTextAreas).map((textarea: any) => textarea.value);
const optionTextAreas = e.target.querySelectorAll<HTMLTextAreaElement>(
'textarea[name="optionText"]'
);
const writingOptionList = Array.from(optionTextAreas).map((textarea, index) => {
return { content: textarea.value, imageURL: options[index]?.imageUrl ?? '' };
});

const updatedPostTexts = {
categoryIds: [1, 2], // 다중 선택 컴포넌트 구현 후 수정 예정
title: writingTitle ?? '',
content: writingContent ?? '',
postOptions: writingOptionTexts,
postOptions: writingOptionList,
deadline: addTimeToDate(time, baseTime),
// 글 수정의 경우 작성시간을 기준으로 마감시간 옵션을 더한다.
// 마감시간 옵션을 선택 안했다면 기존의 마감 시간을 유지한다.
Expand Down