@@ -6,51 +6,57 @@ import { FolderData } from "@/types/folderTypes";
66import { Modal } from "@/components/modal/modalManager/ModalManager" ;
77import { useLinkCardStore } from "@/store/useLinkCardStore" ;
88import { SearchInput } from "../../components/Search/SearchInput" ;
9- import fetchProxy from "@/lib/api/fetchProxy" ;
109import useModalStore from "@/store/useModalStore" ;
10+ import Pagination from "@/components/Pagination" ;
1111import useFetchLinks from "@/hooks/useFetchLinks" ;
12- import CardsLayout from "@/components/Layout/CardsLayout" ;
13- import Container from "@/components/Layout/Container" ;
14- import FolderActionsMenu from "@/components/Folder/FolderActionsMenu" ;
1512import AddLinkInput from "@/components/Link/AddLinkInput" ;
13+ import Container from "@/components/Layout/Container" ;
1614import SearchResultMessage from "@/components/Search/SearchResultMessage" ;
17- import LinkCard from "@/components/Link/LinkCard " ;
15+ import FolderTag from "@/components/Folder/FolderTag " ;
1816import AddFolderButton from "@/components/Folder/AddFolderButton" ;
19- import FolderTag from "../../components/Folder/FolderTag" ;
17+ import FolderActionsMenu from "@/components/Folder/FolderActionsMenu" ;
18+ import CardsLayout from "@/components/Layout/CardsLayout" ;
19+ import LinkCard from "@/components/Link/LinkCard" ;
20+ import fetchProxy from "@/lib/api/fetchProxy" ;
2021
2122interface LinkPageProps {
2223 linkList : LinkData [ ] ;
2324 folderList : FolderData [ ] ;
25+ totalCount : number ;
2426}
2527
2628// /link 페이지 접속시에 초기렌더링 데이터(전체 폴더, 전체링크리스트)만 fetch해서 client로 전달.
2729export const getServerSideProps = async (
2830 context : GetServerSidePropsContext
2931) => {
32+ const { req } = context ;
33+
3034 const [ links , folders ] = await Promise . all ( [
31- fetchProxy ( "/api/links" , context . req ) ,
32- fetchProxy ( "/api/folders" , context . req ) ,
35+ fetchProxy ( "/api/links" , req ) ,
36+ fetchProxy ( "/api/folders" , req ) ,
3337 ] ) ;
3438
3539 return {
3640 props : {
3741 linkList : links . list || [ ] ,
3842 folderList : folders || [ ] ,
43+ totalCount : links . totalCount || 0 ,
3944 } ,
4045 } ;
4146} ;
4247
4348const LinkPage = ( {
4449 linkList : initialLinkList ,
4550 folderList : initialFolderList ,
51+ totalCount,
4652} : LinkPageProps ) => {
4753 const router = useRouter ( ) ;
4854 const { search } = router . query ;
4955 const { isOpen, openModal } = useModalStore ( ) ;
5056 const { linkCardList, setLinkCardList } = useLinkCardStore ( ) ;
5157 const [ folderList , setFolderList ] = useState ( initialFolderList ) ;
5258
53- useFetchLinks ( search , setLinkCardList ) ;
59+ useFetchLinks ( router . query , setLinkCardList ) ;
5460
5561 // 클라이언트에서 초기 목록을 설정
5662 useEffect ( ( ) => {
@@ -94,6 +100,7 @@ const LinkPage = ({
94100 />
95101 ) ) }
96102 </ CardsLayout >
103+ < Pagination totalCount = { totalCount } />
97104 </ Container >
98105 { isOpen && < Modal /> }
99106 </ main >
0 commit comments