@@ -40,9 +40,8 @@ const RefundRequests = () => {
4040 const [ rewardBatches , setRewardBatches ] = useState < Array < RewardBatchDTO > > ( [ ] ) ;
4141 const [ rewardBatchesLoading , setRewardBatchesLoading ] = useState < boolean > ( false ) ;
4242 const [ sendBatchIsLoading , setSendBatchIsLoading ] = useState < boolean > ( false ) ;
43- // const [currentPagination, setCurrentPagination] = useState({ pageNo: 0, pageSize: 10, totalElements: 0 });
43+ const [ currentPagination , setCurrentPagination ] = useState ( { pageNo : 0 , pageSize : 10 , totalElements : 0 } ) ;
4444 const initiativesList = useSelector ( intiativesListSelector ) ;
45-
4645 const columns : Array < GridColDef > = [
4746 {
4847 field : 'spacer' ,
@@ -127,7 +126,6 @@ const RefundRequests = () => {
127126 ) ,
128127 } ,
129128 ] ;
130-
131129 const { t } = useTranslation ( ) ;
132130
133131 useEffect ( ( ) => {
@@ -136,6 +134,15 @@ const RefundRequests = () => {
136134 }
137135 } , [ initiativesList ] ) ;
138136
137+ useEffect ( ( ) => {
138+ const initiativeId =
139+ initiativesList && initiativesList . length > 0 ? initiativesList [ 0 ] . initiativeId : '' ;
140+ void fetchRewardBatches ( initiativeId || '' ) ;
141+ } , [
142+ currentPagination . pageNo ,
143+ currentPagination . pageSize ,
144+ ] ) ;
145+
139146 const infoStyles = {
140147 fontWeight : theme . typography . fontWeightRegular ,
141148 fontSize : theme . typography . fontSize ,
@@ -144,14 +151,19 @@ const RefundRequests = () => {
144151 const fetchRewardBatches = async ( initiativeId : string ) : Promise < void > => {
145152 setRewardBatchesLoading ( true ) ;
146153 try {
147- const response = await getRewardBatches ( initiativeId ) ;
154+ const response = await getRewardBatches ( initiativeId , currentPagination . pageNo , currentPagination . pageSize ) ;
148155 if ( response ?. content ) {
149156 const mappedResponse = response . content . map ( ( value ) => ( {
150157 ...value ,
151158 approvedAmountCents : value . status === 'APPROVED' ? value . approvedAmountCents : undefined ,
152159 suspendedAmountCents : value . status === 'APPROVED' ? value . suspendedAmountCents : undefined
153160 } ) ) ;
154161 setRewardBatches ( mappedResponse ) ;
162+ setCurrentPagination ( {
163+ pageNo : response ?. pageNo as number ,
164+ pageSize : response ?. pageSize as number ,
165+ totalElements : response ?. totalElements as number ,
166+ } ) ;
155167 setSelectedRows ( [ ] ) ;
156168 }
157169 } catch ( error : any ) {
@@ -175,15 +187,7 @@ const RefundRequests = () => {
175187 ) ;
176188
177189 const handlePaginationPageChange = ( page : number ) => {
178- console . log ( 'Page changed:' , page ) ;
179- // const updatedPagination = { ...storesPagination, pageNo: page, initiativeId: id, sort: currentSort };
180- // setStoresPagination(updatedPagination);
181- // sessionStorage.setItem('storesPagination', JSON.stringify(updatedPagination));
182- // void fetchStores({
183- // ...appliedFilters,
184- // page,
185- // sort: currentSort,
186- // });
190+ setCurrentPagination ( ( prev ) => ( { ...prev , pageNo : page } ) ) ;
187191 } ;
188192
189193 const handleRowSelectionChange = ( rows : Array < number > ) => {
@@ -321,7 +325,11 @@ const RefundRequests = () => {
321325 rows = { rewardBatches }
322326 rowsPerPage = { 1 }
323327 checkable = { true }
324- // paginationModel={{ page: currentPagination.pageNo, pageSize: currentPagination.pageSize, totalElements: }}
328+ paginationModel = { {
329+ page : currentPagination . pageNo ,
330+ pageSize : currentPagination . pageSize ,
331+ totalElements : currentPagination . totalElements ,
332+ } }
325333 onPaginationPageChange = { handlePaginationPageChange }
326334 onRowSelectionChange = { handleRowSelectionChange }
327335 isRowSelectable = { isRowSelectable }
0 commit comments