Skip to content

Commit

Permalink
fix: 댓글 등록 버튼 활성화
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunow committed Jun 12, 2024
1 parent c4a9cf7 commit c727c39
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
45 changes: 31 additions & 14 deletions src/pages/ItemDetailPage/components/CommentSection.jsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,47 @@
import { useEffect, useState } from 'react'
import { getItemComments } from '../../../api'
import Comment from './Comment'
import styles from '../styles/CommentSection.module.css'
import { useEffect, useState } from "react";
import { getItemComments } from "../../../api";
import Comment from "./Comment";
import styles from "../styles/CommentSection.module.css";

function CommentSection({ productId }) {
const limit = 3
const [commentList, setCommentList] = useState(null)
const limit = 3;
const [comment, setComment] = useState("");
const [commentList, setCommentList] = useState(null);

const handleInputChange = (e) => {
setComment(e.target.value);
};

const handleSubmit = (e) => {
e.preventDefault();
alert("submit~!");
};

useEffect(() => {
async function fetchComments() {
const data = await getItemComments({ productId, limit })
setCommentList(data.list)
const data = await getItemComments({ productId, limit });
setCommentList(data.list);
}

fetchComments()
}, [productId])
fetchComments();
}, [productId]);

return (
<>
<div className={styles.inputSection}>
<p className={styles.sectionTitle}>문의하기</p>
<input
<textarea
className={styles.input}
value={comment}
onChange={handleInputChange}
placeholder="개인정보를 공유 및 요청하거나, 명예 훼손, 무단 광고, 불법 정보 유포시 모니터링 후 삭제될 수 있으며, 이에 대한 민형사상 책임은 게시자에게 있습니다."
/>
<button className={styles.button} type="submit">
<button
className={styles.button}
type="submit"
onClick={handleSubmit}
disabled={!comment}
>
등록
</button>
</div>
Expand All @@ -34,7 +51,7 @@ function CommentSection({ productId }) {
))}
</div>
</>
)
);
}

export default CommentSection
export default CommentSection;
6 changes: 5 additions & 1 deletion src/pages/ItemDetailPage/styles/CommentSection.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
padding: 12px 23px;
border-radius: 8px;
opacity: 0px;
background-color: #9ca3af;
background-color: #3692ff;
color: #ffffff;
border: none;
}

.button:disabled {
background-color: #9ca3af;
}

0 comments on commit c727c39

Please sign in to comment.