Skip to content

Commit

Permalink
solve
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Feb 17, 2023
1 parent 971815c commit 61f108a
Showing 1 changed file with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ILivechatDepartment, '_updatedAt'>) => <DepartmentItemMenu dep={dep} />;

Expand Down

0 comments on commit 61f108a

Please sign in to comment.