forked from choconaena/RainCatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotice.jsx
71 lines (60 loc) · 1.72 KB
/
Notice.jsx
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
import React, { useEffect, useState } from "react";
import * as S from "./style";
import Banner from "../../components/common/banner/Banner";
import axios from "../../api/axios";
import PostList from "../../components/common/postList/PostList";
import NoticeBanner from "../../components/common/noticeBanner/NoticeBanner";
import Loading from "../../components/common/loading/Loading";
function Notice() {
const [noticeContent, setNoticeContent] = useState([]);
// 현재 페이지
const [currentPage, setCurrentPage] = useState(1);
const [count, setCount] = useState(0);
const [init, setInit] = useState(false);
useEffect(() => {
fetchNoticeContent();
}, []);
const fetchNoticeContent = async () => {
try {
const response = await axios.get(`/notifications?page=${currentPage}`);
const ContentData = response.data.results;
setCount(response.data.count);
setNoticeContent(ContentData);
setInit(true);
} catch (e) {}
};
//페이지변경
useEffect(() => {
fetchNoticeContent();
}, [currentPage]);
return (
<S.NoticeWrapper>
<Banner
titleKorean="공지사항"
titleEnglish="NOTICE"
image={<S.NoticeIconImg />}
/>
<NoticeBanner
title={"공지안내"}
content={"MOIN의 새로운 소식과 공지사항을 확인해보세요!"}
/>
{init ? (
<>
<PostList
use={"notice"}
data={noticeContent}
url={"/notice/"}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
count={count}
/>
</>
) : (
<>
<Loading />
</>
)}
</S.NoticeWrapper>
);
}
export default Notice;