1+ import { useQuery } from '@tanstack/react-query' ;
12import { useState } from 'react' ;
23
3- import { AddIcon , AlarmIcon , DeleteIcon } from '@/assets/icons' ;
4+ import { getRollingPaperList } from '@/apis/rolling' ;
5+ import { AddIcon , AlarmIcon } from '@/assets/icons' ;
46
57import AddRollingPaperModal from './components/AddRollingPaperModal' ;
68import PageTitle from './components/AdminPageTitle' ;
9+ import RollingPaperItem from './components/RollingPaperItem' ;
710import WrapperFrame from './components/WrapperFrame' ;
811import WrapperTitle from './components/WrapperTitle' ;
912
1013export default function AdminRollingPaper ( ) {
1114 const [ activeModal , setActiveModal ] = useState ( false ) ;
15+ const { data, isLoading, isSuccess } = useQuery ( {
16+ queryKey : [ 'admin-rolling-paper' ] ,
17+ queryFn : getRollingPaperList ,
18+ } ) ;
1219
1320 return (
1421 < >
@@ -26,55 +33,32 @@ export default function AdminRollingPaper() {
2633 롤링페이퍼 생성
2734 </ button >
2835 </ section >
29- < table className = "mt-5 table-auto" >
30- < thead >
31- < tr className = "bg-primary-3 border-gray-40 h-14 border-b" >
32- < th className = "w-14 text-center" > ID</ th >
33- < th className = "text-left" > 제목</ th >
34- < th className = "w-30 text-center" > 쌓인 편지 수</ th >
35- < th className = "w-30 text-center" > 상태</ th >
36- < th > </ th >
37- </ tr >
38- </ thead >
39- < tbody >
40- < tr className = "border-gray-40 h-14 border-b" >
41- < td className = "w-14 text-center" > 1</ td >
42- < td className = "text-left" >
43- 침수 피해를 복구중인 포스코 임직원 분들에게 응원의 메시지를 보내주세요!
44- </ td >
45- < td className = "w-30 text-center" > 12</ td >
46- < td className = "text-center" >
47- < span className = "rounded-full border border-amber-500 bg-amber-100/70 px-4 py-1.5 whitespace-nowrap text-amber-500" >
48- 진행 중
49- </ span >
50- </ td >
51- < td > </ td >
52- </ tr >
53- < tr className = "border-gray-40 h-14 border-b" >
54- < td className = "w-14 text-center" > 2</ td >
55- < td className = "text-left" >
56- 침수 피해를 복구중인 포스코 임직원 분들에게 응원의 메시지를 보내주세요!
57- </ td >
58- < td className = "w-30 text-center" > 12</ td >
59- < td className = "w-30 px-2 text-center" >
60- < button
61- type = "button"
62- className = "hover:bg-gray-10 text-gray-60 rounded-md px-3 py-1 hover:text-black"
63- >
64- 진행하기
65- </ button >
66- </ td >
67- < td >
68- < button
69- type = "button"
70- className = "text-gray-60 flex items-center justify-center p-1 hover:text-black"
71- >
72- < DeleteIcon className = "h-5 w-5" />
73- </ button >
74- </ td >
75- </ tr >
76- </ tbody >
77- </ table >
36+ { isLoading && < p className = "mt-20 text-center" > Loading...</ p > }
37+ { isSuccess && (
38+ < >
39+ < table className = "mt-5 table-auto" >
40+ < thead >
41+ < tr className = "bg-primary-3 border-gray-40 h-14 border-b" >
42+ < th className = "w-14 text-center" > ID</ th >
43+ < th className = "text-left" > 제목</ th >
44+ < th className = "w-30 text-center" > 상태</ th >
45+ < th className = "w-6" > </ th >
46+ </ tr >
47+ </ thead >
48+ < tbody >
49+ { data . content . map ( ( rollingPaper ) => (
50+ < RollingPaperItem key = { rollingPaper . eventPostId } information = { rollingPaper } />
51+ ) ) }
52+ </ tbody >
53+ </ table >
54+ { data . content . length === 0 && (
55+ < span className = "my-10 text-center text-gray-50" >
56+ 아직 생성된 롤링페이퍼가 없어요
57+ </ span >
58+ ) }
59+ </ >
60+ ) }
61+ { /* TODO: 페이지네이션 적용 */ }
7862 </ WrapperFrame >
7963 </ >
8064 ) ;
0 commit comments