-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQnAItem.js
More file actions
74 lines (67 loc) · 2.3 KB
/
Copy pathQnAItem.js
File metadata and controls
74 lines (67 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import styles from './QnAItem.module.scss';
import dayjs from 'dayjs';
import { useNavigate, useParams } from 'react-router';
import { useEffect, useState } from 'react';
import axios from 'axios';
import { createRenderer } from 'react-dom/test-utils';
import { IoIosArrowBack } from 'react-icons/io';
import QnAComment from './QnAComment/QnAComment';
const dummyItem = {
id: 0,
title: '타대생도 가입 가능한가요?',
date: '2022.03.01',
comment: 1,
contents: '질문글 내용',
reply: { user: '답글1', comment: '댓글댓글' },
};
const QnAItem = (props) => {
const { circleId, curBoardId, isLoad } = props;
const params = useParams();
const navigate = useNavigate();
const [qnaItem, setQnAItem] = useState({});
const handleQnA = () => {
navigate(`/circle/${params.circleName}/QnA`);
};
useEffect(() => {
if (isLoad) {
axios
.get(`api/v1/circle/${circleId}/board/${curBoardId}/article/${params.id}/`)
.then((response) => {
console.log(response.data);
setQnAItem(response.data);
})
.catch((error) => {
console.log(error);
});
}
}, [isLoad]);
return (
<div className={styles.board_wrapper}>
<div className={styles.header_wrapper}>
<div className={styles.menu_wrapper} onClick={handleQnA}>
<IoIosArrowBack className={styles.arrow} />
<div className={styles.menu}>QnA</div>
</div>
<div className={styles.title_wrapper}>
<div className={styles.title}>{qnaItem.title}</div>
</div>
<div className={styles.info_wrapper}>
<div className={styles.info}>
<div className={styles.author}>{qnaItem.author_username}</div>
<div className={styles.line} />
<div className={styles.date}>{dayjs(qnaItem.created_at).format('YYYY.MM.DD. HH:MM')}</div>
<div className={styles.line} />
<div className={styles.click}>조회 {qnaItem.view}</div>
</div>
</div>
</div>
<div className={styles.content_wrapper}>
<pre className={styles.content}>{qnaItem.content}</pre>
</div>
<div className={styles.comment_wrapper}>
<QnAComment curBoardId={curBoardId} counts={qnaItem.comments_counts} />
</div>
</div>
);
};
export default QnAItem;