From 108d0558993ef15982390e34d9f047d7e15eb022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?s=E1=B4=8F=CA=9F=CA=99=C9=AA=20=E2=98=94=EF=B8=8F?= Date: Thu, 3 Aug 2023 11:17:39 +0900 Subject: [PATCH] =?UTF-8?q?[FE]=20fix:=20=EC=9E=AC=EA=B5=AC=EB=A7=A4=20?= =?UTF-8?q?=EC=B2=A0=EC=9E=90=20=EC=88=98=EC=A0=95=EA=B3=BC=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#280)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 이미지 경로 수정 * fix: api 명세 변경에 따른 이름 수정 --- .../Review/ReviewItem/ReviewItem.tsx | 2 +- .../ReviewRegisterForm/ReviewRegisterForm.tsx | 94 +------------------ 2 files changed, 4 insertions(+), 92 deletions(-) diff --git a/frontend/src/components/Review/ReviewItem/ReviewItem.tsx b/frontend/src/components/Review/ReviewItem/ReviewItem.tsx index f83738c6a..87da477ec 100644 --- a/frontend/src/components/Review/ReviewItem/ReviewItem.tsx +++ b/frontend/src/components/Review/ReviewItem/ReviewItem.tsx @@ -49,7 +49,7 @@ const ReviewItem = ({ productId, review }: ReviewItemProps) => { )} - {image !== null && } + {image !== null && } {content} { const { rating, handleRating } = useStarRating(); const { selectedTags, toggleTagSelection } = useSelectedTags(MIN_DISPLAYED_TAGS_LENGTH); const { content, handleReviewInput } = useReviewTextarea(); - const [reBuy, setReBuy] = useState(false); + const [rebuy, setRebuy] = useState(false); const [submitEnabled, setSubmitEnabled] = useState(false); const { request } = useReviewRegisterForm(product.id); const handleRebuy = (event: React.ChangeEvent) => { - setReBuy(event.target.checked); + setRebuy(event.target.checked); }; - // const handleSubmit: React.FormEventHandler = async (event) => { - // event.preventDefault(); - - // const formData = new FormData(); - - // // if (reviewImage) { - // // formData.append('image', reviewImage); - // // } - - // const reviewRequest = JSON.stringify({ - // rating: rating, - // tagIds: selectedTags, - // content: content, - // rebuy: rebuy, - // }); - - // const jsonBlob = new Blob([reviewRequest], { type: 'application/json' }); - // formData.append('reviewRequest', jsonBlob); - - // const url = `http://3.36.100.213/api/products/${product.id}/reviews`; - - // const headers = { - // 'Content-Type': 'multipart/form-data', - // }; - - // const response = await fetch(url, { - // method: 'POST', - // headers: headers, - // body: formData, - // }); - - // if (!response.ok) { - // throw new Error(`에러 발생 상태코드:${response.status}`); - // } - - // console.log('리뷰가 성공적으로 등록되었습니다.'); - - // // 다음 작업을 수행... - - // // await request(formData); - // }; - const handleSubmit: React.FormEventHandler = async (event) => { event.preventDefault(); @@ -91,23 +49,17 @@ const ReviewRegisterForm = ({ product, close }: ReviewRegisterFormProps) => { formData.append('image', reviewImageFile, reviewImageFile.name); } - // formData.append('image', reviewImageFile); - - // JSON 리뷰 데이터에 이러한 속성들을 추가 const reviewRequest = { rating, tagIds: selectedTags, content, - reBuy, + rebuy, }; - // JSON 리뷰 데이터를 문자열로 변환 const jsonString = JSON.stringify(reviewRequest); - // 문자열을 Blob 객체로 변환. mimeType은 'application/json'으로 설정 const jsonBlob = new Blob([jsonString], { type: 'application/json' }); - // 리뷰 요청으로 JSON Blob 객체를 추가 formData.append('reviewRequest', jsonBlob); const url = `https://funeat.site/api/products/${product.id}/reviews`; @@ -123,48 +75,8 @@ const ReviewRegisterForm = ({ product, close }: ReviewRegisterFormProps) => { } console.log(response, '리뷰가 성공적으로 등록되었습니다.'); - - // await request(formData); }; - // const handleSubmit: React.FormEventHandler = async (event) => { - // event.preventDefault(); - - // const formData = new FormData(); - - // formData.append('image', reviewImage ?? null); - // formData.append( - // 'reviewRequest', - // JSON.stringify({ - // rating, - // tagIds: selectedTags, - // content, - // reBuy, - // }) - // ); - - // const url = `https://funeat.site/api/products/${product.id}/reviews`; - - // // const headers = { - // // 'Content-Type': 'multipart/form-data', - // // }; - - // const response = await fetch(url, { - // method: 'POST', - // // headers: headers, - // body: formData, - // credentials: 'include', - // }); - - // if (!response.ok) { - // throw new Error(`에러 발생 상태코드:${response.status}`); - // } - - // console.log(response, '리뷰가 성공적으로 등록되었습니다.'); - - // // await request(formData); - // }; - // useEffect(() => { // const isValid = // rating > MIN_RATING_SCORE &&