Skip to content

Commit

Permalink
[FE] fix: 재구매 철자 수정과 이미지 경로 수정 (#280)
Browse files Browse the repository at this point in the history
* fix: 이미지 경로 수정

* fix: api 명세 변경에 따른 이름 수정
  • Loading branch information
hae-on authored Aug 3, 2023
1 parent ece9741 commit 108d055
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 92 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Review/ReviewItem/ReviewItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ReviewItem = ({ productId, review }: ReviewItemProps) => {
</RebuyBadge>
)}
</ReviewerWrapper>
{image !== null && <ReviewImage src={image} height={150} alt={`${userName}의 리뷰`} />}
{image !== null && <ReviewImage src={`/images/${image}`} height={150} alt={`${userName}의 리뷰`} />}
<TagList tags={tags} />
<Text css="white-space: pre-wrap">{content}</Text>
<FavoriteButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,57 +31,15 @@ const ReviewRegisterForm = ({ product, close }: ReviewRegisterFormProps) => {
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<HTMLInputElement>) => {
setReBuy(event.target.checked);
setRebuy(event.target.checked);
};

// const handleSubmit: React.FormEventHandler<HTMLFormElement> = 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<HTMLFormElement> = async (event) => {
event.preventDefault();

Expand All @@ -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`;
Expand All @@ -123,48 +75,8 @@ const ReviewRegisterForm = ({ product, close }: ReviewRegisterFormProps) => {
}

console.log(response, '리뷰가 성공적으로 등록되었습니다.');

// await request(formData);
};

// const handleSubmit: React.FormEventHandler<HTMLFormElement> = 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 &&
Expand Down

0 comments on commit 108d055

Please sign in to comment.