From 61f108aeab7f1a72c2a35624f38161419ca25249 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 17 Feb 2023 18:22:47 -0300 Subject: [PATCH] solve --- .../departments/DepartmentsPageWithData.tsx | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/meteor/client/views/omnichannel/departments/DepartmentsPageWithData.tsx b/apps/meteor/client/views/omnichannel/departments/DepartmentsPageWithData.tsx index 60e8a58a779c..8d46b29076c3 100644 --- a/apps/meteor/client/views/omnichannel/departments/DepartmentsPageWithData.tsx +++ b/apps/meteor/client/views/omnichannel/departments/DepartmentsPageWithData.tsx @@ -17,20 +17,23 @@ const DepartmentsPageWithData = (): ReactElement => { const pagination = usePagination(); const sort = useSort<'name' | 'email' | 'active'>('name'); - const query = { - onlyMyDepartments: 'true' as const, - text: debouncedText, - sort: JSON.stringify({ [sort.sortBy]: sort.sortDirection === 'asc' ? 1 : -1 }), - ...(pagination.current && { offset: pagination.current }), - ...(pagination.itemsPerPage && { count: pagination.itemsPerPage }), - fields: JSON.stringify({ name: 1, username: 1, emails: 1, avatarETag: 1 }), - }; - const getDepartments = useEndpoint('GET', '/v1/livechat/department'); - const result = useQuery(['omnichannel', 'departments', query], () => getDepartments(query), { - keepPreviousData: true, - }); + const result = useQuery( + ['omnichannel', 'departments', debouncedText, pagination, sort], + () => + getDepartments({ + onlyMyDepartments: 'true' as const, + text: debouncedText, + sort: JSON.stringify({ [sort.sortBy]: sort.sortDirection === 'asc' ? 1 : -1 }), + ...(pagination.current && { offset: pagination.current }), + ...(pagination.itemsPerPage && { count: pagination.itemsPerPage }), + fields: JSON.stringify({ name: 1, username: 1, emails: 1, avatarETag: 1 }), + }), + { + keepPreviousData: true, + }, + ); const removeButton = (dep: Omit) => ;