66} from "@/context/ActionViewContext" ;
77import { ColumnState } from "@gisce/react-formiga-table" ;
88import { DEFAULT_PAGE_SIZE } from "@/hooks/usePaginatedSearch" ;
9+ import { DEFAULT_SEARCH_LIMIT } from "@/models/constants" ;
910import {
1011 DEFAULT_TREE_TYPE ,
1112 TreeType ,
@@ -35,14 +36,14 @@ export type SearchTreeState = {
3536 totalItems : number ;
3637 setTotalItems : ( value : number ) => void ;
3738 isActive ?: boolean ;
38- sortState ?: ColumnState [ ] ;
39- setSortState : ( value : ColumnState [ ] | undefined ) => void ;
40- pageSize : number ;
41- setPageSize : ( value : number ) => void ;
39+ order ?: ColumnState [ ] ;
40+ setOrder : ( value : ColumnState [ ] | undefined ) => void ;
4241 currentPage : number ;
4342 setCurrentPage : ( value : number ) => void ;
4443 treeType : TreeType ;
4544 setTreeType : ( value : TreeType ) => void ;
45+ limit : number ;
46+ setLimit : ( value : number ) => void ;
4647} ;
4748
4849export function useSearchTreeState ( {
@@ -68,13 +69,11 @@ export function useSearchTreeState({
6869 const [ localResults , setLocalResults ] = useState < any [ ] > ( [ ] ) ;
6970 const [ localSearchQuery , setLocalSearchQuery ] = useState < SearchQueryParams > ( ) ;
7071 const [ localTotalItems , setLocalTotalItems ] = useState ( 0 ) ;
71- const [ localSortState , setLocalSortState ] = useState <
72- ColumnState [ ] | undefined
73- > ( ) ;
74- const [ localPageSize , setLocalPageSize ] = useState < number > ( DEFAULT_PAGE_SIZE ) ;
72+ const [ localOrder , setLocalOrder ] = useState < ColumnState [ ] | undefined > ( ) ;
7573 const [ localCurrentPage , setLocalCurrentPage ] = useState < number > ( 1 ) ;
7674 const [ localTreeType , setLocalTreeType ] =
7775 useState < TreeType > ( DEFAULT_TREE_TYPE ) ;
76+ const [ localLimit , setLocalLimit ] = useState < number > ( DEFAULT_SEARCH_LIMIT ) ;
7877
7978 // Return either context values or local state values based on isUnderActionViewContext
8079 return isUnderActionViewContext
@@ -106,14 +105,14 @@ export function useSearchTreeState({
106105 totalItems : actionViewContext . totalItems ?? 0 ,
107106 setTotalItems : actionViewContext . setTotalItems ?? ( ( ) => { } ) ,
108107 isActive : actionViewContext . isActive ,
109- sortState : actionViewContext . sortState ,
110- setSortState : actionViewContext . setSortState ?? ( ( ) => { } ) ,
111- pageSize : actionViewContext . pageSize ?? DEFAULT_PAGE_SIZE ,
112- setPageSize : actionViewContext . setPageSize ?? ( ( ) => { } ) ,
108+ order : actionViewContext . order ,
109+ setOrder : actionViewContext . setOrder ?? ( ( ) => { } ) ,
113110 currentPage : actionViewContext . currentPage ?? 1 ,
114111 setCurrentPage : actionViewContext . setCurrentPage ?? ( ( ) => { } ) ,
115112 treeType : actionViewContext . treeType ?? DEFAULT_TREE_TYPE ,
116113 setTreeType : actionViewContext . setTreeType ?? ( ( ) => { } ) ,
114+ limit : actionViewContext . limit ?? DEFAULT_SEARCH_LIMIT ,
115+ setLimit : actionViewContext . setLimit ?? ( ( ) => { } ) ,
117116 }
118117 : {
119118 treeIsLoading : localTreeIsLoading ,
@@ -139,13 +138,13 @@ export function useSearchTreeState({
139138 totalItems : localTotalItems ,
140139 setTotalItems : setLocalTotalItems ,
141140 isActive : undefined ,
142- sortState : localSortState ,
143- setSortState : setLocalSortState ,
144- pageSize : localPageSize ,
145- setPageSize : setLocalPageSize ,
141+ order : localOrder ,
142+ setOrder : setLocalOrder ,
146143 currentPage : localCurrentPage ,
147144 setCurrentPage : setLocalCurrentPage ,
148145 treeType : localTreeType ,
149146 setTreeType : setLocalTreeType ,
147+ limit : localLimit ,
148+ setLimit : setLocalLimit ,
150149 } ;
151150}
0 commit comments