Skip to content

Commit

Permalink
카테고리별 게시글 조회 기능을 위해 getPostList 함수 수정 이후 usePostList 훅 추가 기능 구현 (#113)
Browse files Browse the repository at this point in the history
* feat: (#110) 게시글 목록 패치 함수 및 훅에서 카테고리별 게시글 목록을 불러오도록 수정

* feat: (#110) PostList 컴포넌트에서 categoryId를 이용해 카테고리별 게시글 목록을 요청할 수 있도록 구현

* refactor: (#110) 컴포넌트에서만 사용되는 상수의 위치 변경

* refactor: (#110) URLSearchParams에서 useSearchParams로 변경

* refactor: (#110) 카테고리별 글 목록 URL을 반환하는 함수의 이름 변경 및 반복되는 코드 변경

* refactor: (#110) 카테고리별 게시글 URL 경로 및 API 연동 코드 추가
  • Loading branch information
Gilpop8663 authored and chsua committed Jul 26, 2023
1 parent e4b8d1c commit 35f6a35
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/components/PostForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps
endTime: deadline,
voteInfo,
} = data ?? {};
const options = voteInfo?.options ?? [];

const navigate = useNavigate();

console.log(options);
const { isOpen, openComponent, closeComponent } = useToggle();
const [time, setTime] = useState({
day: 0,
Expand Down Expand Up @@ -85,13 +87,15 @@ 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 writingOptionList = Array.from(optionTextAreas).map((textarea: any, 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 All @@ -105,7 +109,7 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps
return;
}

navigate('/');
// navigate('/');
}
};

Expand Down

0 comments on commit 35f6a35

Please sign in to comment.