@@ -22,7 +22,7 @@ const useMaster = ({ defaultLimit, routes, defaultSort = ["createdAt", 1], preCo
2222 const sortConfigRef = useRef < SortConfigType > ( defaultSort )
2323
2424 const { baseUrl, token, dataGetter, paginationGetter, onError, onLogout, onSuccess } = useProviderState ( )
25- const { currentPage, offsetRef, limitRef, currentPageRef } = usePagination ( {
25+ const { currentPage, offsetRef, limitRef, currentPageRef, searchStr , setSearchStr , searchRef } = usePagination ( {
2626 defaultLimit,
2727 } )
2828
@@ -60,7 +60,6 @@ const useMaster = ({ defaultLimit, routes, defaultSort = ["createdAt", 1], preCo
6060 } )
6161 if ( response ?. code === "SUCCESS" ) {
6262 setLoading ( false )
63- if ( search ) currentPageRef . current = 1
6463 setTotalPages ( paginationGetter ( response ) . totalPages )
6564 setTotalRecords ( paginationGetter ( response ) . totalDocs )
6665 return setList ( dataGetter ( response ) )
@@ -205,7 +204,7 @@ const useMaster = ({ defaultLimit, routes, defaultSort = ["createdAt", 1], preCo
205204 }
206205 const onChangeCurrentPage = ( page : number ) : void => {
207206 currentPageRef . current = page
208- getMastersList ( )
207+ getMastersList ( searchRef . current )
209208 }
210209 useEffect ( ( ) => {
211210 getMastersList ( )
@@ -237,6 +236,10 @@ const useMaster = ({ defaultLimit, routes, defaultSort = ["createdAt", 1], preCo
237236 onCloseForm,
238237 onDataSubmit,
239238 onCofirmDeleteMaster,
239+
240+ // Search
241+ searchStr,
242+ setSearchStr,
240243 }
241244}
242245
0 commit comments