99} from '@app-builder/components/Cases/Filters' ;
1010import { InputWithButton } from '@app-builder/components/InputWithButton' ;
1111import { useCursorPaginatedFetcher } from '@app-builder/hooks/useCursorPaginatedFetcher' ;
12+ import useIntersection from '@app-builder/hooks/useIntersection' ;
1213import { isForbiddenHttpError , isNotFoundHttpError } from '@app-builder/models' ;
1314import { type Case , type CaseStatus , caseStatuses } from '@app-builder/models/cases' ;
1415import { type PaginatedResponse , type PaginationParams } from '@app-builder/models/pagination' ;
@@ -25,7 +26,7 @@ import { type LoaderFunctionArgs, redirect } from '@remix-run/node';
2526import { useLoaderData , useNavigate } from '@remix-run/react' ;
2627import { type Namespace } from 'i18next' ;
2728import qs from 'qs' ;
28- import { useCallback } from 'react' ;
29+ import { useCallback , useEffect , useRef } from 'react' ;
2930import { useTranslation } from 'react-i18next' ;
3031import { omit } from 'remeda' ;
3132import { Button , cn } from 'ui-design-system' ;
@@ -212,11 +213,23 @@ export default function Cases() {
212213 [ navigate , inboxId , next , previous , reset ] ,
213214 ) ;
214215
216+ const paginationSentinelRef = useRef < HTMLDivElement > ( null ) ;
217+ const containerRef = useRef < HTMLDivElement > ( null ) ;
218+ const paginationIntersection = useIntersection ( paginationSentinelRef , {
219+ root : containerRef . current ,
220+ rootMargin : '-24px' ,
221+ threshold : 0 ,
222+ } ) ;
223+
224+ useEffect ( ( ) => {
225+ containerRef . current ?. scrollTo ( { top : 0 } ) ;
226+ } , [ cases ] ) ;
227+
215228 return (
216229 < CaseRightPanel . Root >
217- < Page . Container >
218- < Page . Content >
219- < div className = "flex flex-col gap-4" >
230+ < Page . Container ref = { containerRef } >
231+ < Page . ContentV2 >
232+ < div className = "flex flex-col gap-4 relative " >
220233 < CasesFiltersProvider submitCasesFilters = { navigateCasesList } filterValues = { filters } >
221234 < div className = "flex justify-between" >
222235 < div className = "flex gap-4 items-center" >
@@ -262,7 +275,6 @@ export default function Cases() {
262275 < CasesList
263276 key = { inboxId }
264277 cases = { cases }
265- className = "max-h-[60dvh]"
266278 initSorting = { [
267279 {
268280 id : initialPagination . sorting ?? 'created_at' ,
@@ -279,7 +291,15 @@ export default function Cases() {
279291 hasAlreadyOrdered = true ;
280292 } }
281293 />
282- < div className = "flex justify-between gap-8" >
294+ < div
295+ className = { cn (
296+ 'flex justify-between gap-8 sticky bottom-0 z-10 bg-purple-99 -mb-v2-lg -mx-v2-lg p-v2-lg pt-v2-md border-t border-purple-99' ,
297+ {
298+ 'shadow-sticky-bottom border-t-grey-95' :
299+ ! paginationIntersection ?. isIntersecting ,
300+ } ,
301+ ) }
302+ >
283303 < div className = "flex gap-2 items-center" >
284304 < span > { t ( 'cases:list.results_per_page' ) } </ span >
285305 { [ 25 , 50 , 100 ] . map ( ( limit ) => {
@@ -313,8 +333,9 @@ export default function Cases() {
313333 />
314334 </ div >
315335 </ CasesFiltersProvider >
336+ < div ref = { paginationSentinelRef } className = "absolute left-0 bottom-0" />
316337 </ div >
317- </ Page . Content >
338+ </ Page . ContentV2 >
318339 </ Page . Container >
319340 </ CaseRightPanel . Root >
320341 ) ;
0 commit comments