-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feat/#60 write comment
- Loading branch information
Showing
10 changed files
with
183 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import axios from "axios"; | ||
import { useNavigate, useLocation } from "react-router-dom"; | ||
import styles from './reviewComment.module.css'; | ||
import { useState } from "react"; | ||
|
||
export default function ReviewComment() { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
|
||
const tab = 'Review'; | ||
const [comment, setComment] = useState(""); | ||
|
||
const clubId = location.state.clubId; | ||
const selectedKeywords = location.state.selectedKeywords; | ||
console.log(clubId); | ||
console.log(selectedKeywords); | ||
|
||
const saveComment = (event) => { | ||
setComment(event.target.value); | ||
console.log(event.target.value); | ||
} | ||
|
||
const onClickPass = async () => { | ||
try { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
const res = await axios.post( | ||
`http://13.125.141.171:8080/v1/clubs/${clubId}/reviews`, | ||
{ | ||
keywords: selectedKeywords, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
} | ||
); | ||
console.log('리뷰 작성 성공:', res.data); | ||
navigate(`/clubs/${clubId}`, { state: tab }); // 해당 동아리 상세 페이지로 이동 -> 폴더구조 정리해서 리뷰페이지로 이동하게 | ||
// setBtnActive({}); // 제출 후 버튼 상태를 초기화 | ||
} catch (error) { | ||
console.error('리뷰 작성 실패:', error); | ||
} | ||
} | ||
|
||
const onClickSubmit = async () => { | ||
console.log(comment); | ||
try { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
const res = await axios.post( | ||
`http://13.125.141.171:8080/v1/clubs/${clubId}/reviews/v2?clubId=${clubId}`, | ||
{ | ||
content: comment, | ||
keywords: selectedKeywords, | ||
}, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
} | ||
); | ||
console.log('리뷰 작성 성공:', res.data); | ||
navigate(`/clubs/${clubId}`, { state: tab }); // 해당 동아리 상세 페이지로 이동 -> 폴더구조 정리해서 리뷰페이지로 이동하게 | ||
// setBtnActive({}); // 제출 후 버튼 상태를 초기화 | ||
} catch (error) { | ||
console.error('리뷰 작성 실패:', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<h2 className={styles.title}>한줄평을 자유롭게 써주세요!</h2> | ||
<input type="text" placeholder="작성하기" onChange={saveComment} /> | ||
<div className={styles.buttonContainer}> | ||
<button onClick={onClickPass}>넘어가기</button> | ||
<button onClick={onClickSubmit}>작성하기</button> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin-bottom: 500px; | ||
} | ||
|
||
.title { | ||
width: 380px; | ||
height: 40px; | ||
text-align: center; | ||
font-family: Noto Sans KR; | ||
font-size: 24px; | ||
font-weight: 600; | ||
line-height: 34.75px; | ||
margin: auto; | ||
margin-bottom: 20px; | ||
margin-top: 39px; | ||
} | ||
|
||
input { | ||
width: 50%; | ||
height: 50px; | ||
border: 1px solid #00000033; | ||
border-radius: 10px; | ||
|
||
font-family: Noto Sans KR; | ||
font-weight: 400; | ||
margin-bottom: 30px; | ||
} | ||
|
||
input::placeholder { | ||
color: #9C9C9CB2; | ||
} | ||
|
||
.buttonContainer { | ||
width: 16%; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
} | ||
|
||
.buttonContainer button { | ||
height: 40px; | ||
margin: 20px 5px; | ||
background-color: #7BC8E0; | ||
color: white; | ||
text-align: center; | ||
font-weight: 600; | ||
border-radius: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters