Skip to content

Commit

Permalink
feat: order
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Feb 13, 2025
1 parent ed570ca commit 824c304
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions src/context/ActionViewContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export type ActionViewContextType = Omit<
setSearchQuery?: (value: SearchQueryParams) => void;
treeType?: TreeType;
setTreeType?: (value: TreeType) => void;
sortState?: ColumnState[];
setSortState?: (value: ColumnState[] | undefined) => void;
order?: ColumnState[];
setOrder?: (value: ColumnState[] | undefined) => void;
currentPage?: number;
setCurrentPage?: (value: number) => void;
};
Expand Down Expand Up @@ -152,7 +152,7 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
>(undefined);
const [searchQuery, setSearchQuery] = useState<SearchQueryParams>();
const [treeType, setTreeType] = useState<TreeType>(DEFAULT_TREE_TYPE);
const [sortState, setSortState] = useState<ColumnState[]>();
const [order, setOrder] = useState<ColumnState[]>();

const [limit, setLimit] = useState<number>(
limitProps !== undefined ? limitProps : DEFAULT_SEARCH_LIMIT,
Expand Down Expand Up @@ -265,8 +265,8 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
setSearchQuery,
treeType,
setTreeType,
sortState,
setSortState,
order,
setOrder,
currentPage,
setCurrentPage,
}}
Expand Down Expand Up @@ -347,8 +347,8 @@ export const useActionViewContext = () => {
setSearchQuery: () => {},
treeType: DEFAULT_TREE_TYPE,
setTreeType: () => {},
sortState: undefined,
setSortState: () => {},
order: undefined,
setOrder: () => {},
currentPage: 1,
setCurrentPage: () => {},
};
Expand Down
17 changes: 8 additions & 9 deletions src/hooks/usePaginatedSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export const usePaginatedSearch = (props: PaginatedSearchProps) => {
isActive,
currentPage,
setCurrentPage,
sortState: actionViewSortState,
setSortState: setActionViewSortState,
order: actionViewOrder,
setOrder: setActionViewOrder,
limit,
setLimit,
} = useSearchTreeState({ useLocalState: !rootTree });
Expand Down Expand Up @@ -283,7 +283,7 @@ export const usePaginatedSearch = (props: PaginatedSearchProps) => {
mergedParams,
nameSearch,
domain,
actionViewSortState,
actionViewOrder,
]);

useEffect(() => {
Expand Down Expand Up @@ -336,9 +336,9 @@ export const usePaginatedSearch = (props: PaginatedSearchProps) => {
}

let order;
if (actionViewSortState?.length) {
if (actionViewOrder?.length) {
const sortFields = getSortedFieldsFromState({
state: actionViewSortState,
state: actionViewOrder,
});
order = getOrderFromSortFields(sortFields);
}
Expand Down Expand Up @@ -411,7 +411,7 @@ export const usePaginatedSearch = (props: PaginatedSearchProps) => {
treeOoui,
treeViewFetching,
setTreeIsLoading,
actionViewSortState,
actionViewOrder,
nameSearch,
domain,
mergedParams,
Expand Down Expand Up @@ -529,9 +529,8 @@ export const usePaginatedSearch = (props: PaginatedSearchProps) => {
updateColumnState,
currentPage,
limit,
sortState: actionViewSortState,
setSortState: setActionViewSortState,
treeFirstVisibleColumn,
order: actionViewOrder,
setOrder: setActionViewOrder,
setTreeFirstVisibleColumn,
onGetFirstVisibleColumn,
};
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useUrlFromCurrentTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useUrlFromCurrentTab({
}: {
currentTab?: Tab;
}): UseUrlFromCurrentTabResult {
const { currentView, searchParams, currentId, limit, currentPage } =
const { currentView, searchParams, currentId, limit, currentPage, order } =
useActionViewContext();
const { currentTab: currentTabContext } = useTabs();

Expand All @@ -36,6 +36,7 @@ export function useUrlFromCurrentTab({
...(currentId && { res_id: currentId }),
...(limit && { limit }),
...(currentPage && currentPage > 1 && { currentPage }),
...(order && { order }),
};

const shareUrl = createShareOpenUrl(finalActionData);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/views/SearchTreeInfinite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ function SearchTreeInfiniteComp(props: SearchTreeInfiniteProps, ref: any) {
setSearchQuery,
setTotalItems: setTotalItemsActionView,
isActive,
sortState: actionViewSortState,
setSortState: setActionViewSortState,
order: actionViewSortState,
setOrder: setActionViewSortState,
} = useSearchTreeState({ useLocalState: !rootTree });

const nameSearch = nameSearchProps || searchTreeNameSearch;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/views/Tree/Paginated/SearchTreePaginated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ function SearchTreePaginatedComp(props: SearchTreePaginatedProps, ref: any) {
updateColumnState,
currentPage,
limit,
sortState: actionViewSortState,
setSortState: setActionViewSortState,
order: actionViewSortState,
setOrder: setActionViewSortState,
setTreeFirstVisibleColumn,
onGetFirstVisibleColumn,
} = usePaginatedSearch({
Expand Down

0 comments on commit 824c304

Please sign in to comment.