From 35f6a3547601ebb7fd62f0d3fcd85adc76772b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=98=81=EA=B8=B8/KIM=20YOUNG=20GIL?= <80146176+Gilpop8663@users.noreply.github.com> Date: Tue, 25 Jul 2023 17:20:04 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=EC=B9=B4=ED=85=8C=EA=B3=A0=EB=A6=AC?= =?UTF-8?q?=EB=B3=84=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EC=9C=84=ED=95=B4=20getPostList?= =?UTF-8?q?=20=ED=95=A8=EC=88=98=20=EC=88=98=EC=A0=95=20=EC=9D=B4=ED=9B=84?= =?UTF-8?q?=20usePostList=20=ED=9B=85=20=EC=B6=94=EA=B0=80=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84=20(#113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: (#110) 게시글 목록 패치 함수 및 훅에서 카테고리별 게시글 목록을 불러오도록 수정 * feat: (#110) PostList 컴포넌트에서 categoryId를 이용해 카테고리별 게시글 목록을 요청할 수 있도록 구현 * refactor: (#110) 컴포넌트에서만 사용되는 상수의 위치 변경 * refactor: (#110) URLSearchParams에서 useSearchParams로 변경 * refactor: (#110) 카테고리별 글 목록 URL을 반환하는 함수의 이름 변경 및 반복되는 코드 변경 * refactor: (#110) 카테고리별 게시글 URL 경로 및 API 연동 코드 추가 --- frontend/src/components/PostForm/index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index c9e11847d..0cc34291e 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -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, @@ -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), // 글 수정의 경우 작성시간을 기준으로 마감시간 옵션을 더한다. // 마감시간 옵션을 선택 안했다면 기존의 마감 시간을 유지한다. @@ -105,7 +109,7 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps return; } - navigate('/'); + // navigate('/'); } }; From 6332b1a6b284fc441628028984b0a4c0f149ad0f Mon Sep 17 00:00:00 2001 From: chsua Date: Wed, 26 Jul 2023 20:05:03 +0900 Subject: [PATCH 2/7] =?UTF-8?q?refactor:=20(#145)=20=EA=B8=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20api,=20body=ED=98=95=ED=83=9C=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/PostForm/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index 0cc34291e..c7c021737 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -88,7 +88,9 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps const optionTextAreas = e.target.querySelectorAll('textarea[name="optionText"]'); const writingOptionList = Array.from(optionTextAreas).map((textarea: any, index) => { - return { content: textarea.value, imageURL: options[index].imageUrl }; + return options.length === 0 + ? textarea.value + : { content: textarea.value, imageURL: options[index].imageUrl }; }); const updatedPostTexts = { From cfab3123f1ad9064da2baf59054e55cba5bc4329 Mon Sep 17 00:00:00 2001 From: chsua Date: Wed, 26 Jul 2023 20:17:00 +0900 Subject: [PATCH 3/7] =?UTF-8?q?style:=20(#145)=20console.log=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/PostForm/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index c7c021737..03bc28f0a 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -42,7 +42,6 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps const navigate = useNavigate(); - console.log(options); const { isOpen, openComponent, closeComponent } = useToggle(); const [time, setTime] = useState({ day: 0, From aafbb286ec2613e07bc7f3c8688d95ae170dfd21 Mon Sep 17 00:00:00 2001 From: chsua Date: Wed, 26 Jul 2023 20:18:03 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor:=20(#145)=20=EA=B0=81=EC=A3=BC?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=ED=95=9C=20nav=20=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/PostForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index 03bc28f0a..3e7386bb3 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -110,7 +110,7 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps return; } - // navigate('/'); + navigate('/'); } }; From f1b2b5641207df5c6ec25ffae08ef7eaeb861ef6 Mon Sep 17 00:00:00 2001 From: chsua Date: Thu, 27 Jul 2023 11:05:45 +0900 Subject: [PATCH 5/7] =?UTF-8?q?refactor:=20(#123)=20=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20api=20=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/PostForm/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index 3e7386bb3..ada0ed51f 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -87,9 +87,7 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps const optionTextAreas = e.target.querySelectorAll('textarea[name="optionText"]'); const writingOptionList = Array.from(optionTextAreas).map((textarea: any, index) => { - return options.length === 0 - ? textarea.value - : { content: textarea.value, imageURL: options[index].imageUrl }; + return { content: textarea.value, imageURL: options[index].imageUrl }; }); const updatedPostTexts = { From f143a6430f20e208b0ae3407be90b01a32b307d7 Mon Sep 17 00:00:00 2001 From: chsua Date: Thu, 27 Jul 2023 11:06:35 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor:=20(#123)=20=EC=84=A0=ED=83=9D?= =?UTF-8?q?=EC=A7=80=20=EB=82=B4=EC=9A=A9=EC=9E=85=EB=A0=A5=20element=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=A7=80=EC=A0=95=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/PostForm/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index ada0ed51f..5fe7d828d 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -85,8 +85,10 @@ 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 writingOptionList = Array.from(optionTextAreas).map((textarea: any, index) => { + const optionTextAreas = e.target.querySelectorAll( + 'textarea[name="optionText"]' + ); + const writingOptionList = Array.from(optionTextAreas).map((textarea, index) => { return { content: textarea.value, imageURL: options[index].imageUrl }; }); From c65920bf8fd2d2044ae5e14e8d6cd429780015b0 Mon Sep 17 00:00:00 2001 From: chsua Date: Thu, 27 Jul 2023 11:11:48 +0900 Subject: [PATCH 7/7] =?UTF-8?q?feat:=20(#145)=20=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20api=20=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/PostForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/PostForm/index.tsx b/frontend/src/components/PostForm/index.tsx index 5fe7d828d..39df8a841 100644 --- a/frontend/src/components/PostForm/index.tsx +++ b/frontend/src/components/PostForm/index.tsx @@ -89,7 +89,7 @@ export default function PostForm({ data, mutate, isError, error }: PostFormProps 'textarea[name="optionText"]' ); const writingOptionList = Array.from(optionTextAreas).map((textarea, index) => { - return { content: textarea.value, imageURL: options[index].imageUrl }; + return { content: textarea.value, imageURL: options[index]?.imageUrl ?? '' }; }); const updatedPostTexts = {