11import React , { useEffect , useState } from 'react' ;
2- import { useProjectCardListData } from '../../../../hooks/useProjectCardListData' ;
3- import { useSaveSearchFiltering } from '../../../../hooks/useSaveSearchFiltering' ;
42import * as S from './Pagination.styled' ;
53import {
64 ChevronLeftIcon ,
75 ChevronRightIcon ,
86 EllipsisHorizontalIcon ,
97} from '@heroicons/react/24/outline' ;
108
11- export default function Pagination ( ) {
12- const { projectListsData } = useProjectCardListData ( ) ;
13- const { searchFilters, handleUpdateFilters } = useSaveSearchFiltering ( ) ;
14- const lastPage = projectListsData ?. lastPage ;
15- const currentPage = searchFilters . page ;
9+ interface PaginationProps {
10+ page : number ;
11+ getLastPage : number ;
12+ onChangePagination : ( page : number ) => void ;
13+ }
14+
15+ export default function Pagination ( {
16+ page,
17+ getLastPage,
18+ onChangePagination,
19+ } : PaginationProps ) {
20+ const lastPage = getLastPage ;
21+ const currentPage = page ;
1622
1723 const calculatePageRange = ( ) => {
1824 if ( ! lastPage ) return ;
@@ -39,22 +45,19 @@ export default function Pagination() {
3945 const target = e . target as HTMLElement ;
4046 const dataId = target . dataset . id ;
4147 if ( ! dataId ) return ;
42- handleUpdateFilters ( 'page' , Number ( dataId ) ) ;
48+ onChangePagination ( Number ( dataId ) ) ;
4349 } ;
44-
4550 return (
4651 < S . Container >
4752 < S . Wrapper onClick = { handleMovePaginationClick } >
4853 { currentPage !== 1 && (
4954 < >
5055 < S . PaginationButton
51- onClick = { ( ) => handleUpdateFilters ( 'page' , currentPage - 1 ) }
56+ onClick = { ( ) => onChangePagination ( currentPage - 1 ) }
5257 >
5358 < ChevronLeftIcon />
5459 </ S . PaginationButton >
55- < S . PaginationDoubleButton
56- onClick = { ( ) => handleUpdateFilters ( 'page' , 1 ) }
57- >
60+ < S . PaginationDoubleButton onClick = { ( ) => onChangePagination ( 1 ) } >
5861 1
5962 </ S . PaginationDoubleButton >
6063 < EllipsisHorizontalIcon />
@@ -74,12 +77,12 @@ export default function Pagination() {
7477 < >
7578 < EllipsisHorizontalIcon />
7679 < S . PaginationDoubleButton
77- onClick = { ( ) => handleUpdateFilters ( 'page' , lastPage ) }
80+ onClick = { ( ) => onChangePagination ( lastPage ) }
7881 >
7982 { lastPage }
8083 </ S . PaginationDoubleButton >
8184 < S . PaginationButton
82- onClick = { ( ) => handleUpdateFilters ( 'page' , currentPage + 1 ) }
85+ onClick = { ( ) => onChangePagination ( currentPage + 1 ) }
8386 >
8487 < ChevronRightIcon />
8588 </ S . PaginationButton >
0 commit comments