From 8db7b92983f589c2c839567fd29fdcdfeb77d21b Mon Sep 17 00:00:00 2001 From: Douglas Fabris Date: Thu, 26 Oct 2023 13:35:19 -0300 Subject: [PATCH] chore: Refactor Omnichannel Edit Tags UI (#30732) --- .../AutoCompleteDepartmentMultiple.tsx | 3 +- .../omnichannel/priorities/PriorityList.tsx | 3 +- .../omnichannel/tags/RemoveTagButton.tsx | 42 ------ .../ee/client/omnichannel/tags/TagEdit.js | 99 ------------ .../ee/client/omnichannel/tags/TagEdit.tsx | 141 ++++++++++++++++++ .../omnichannel/tags/TagEditWithData.js | 38 ----- .../omnichannel/tags/TagEditWithData.tsx | 36 +++++ .../tags/TagEditWithDepartmentData.tsx | 42 ++---- .../ee/client/omnichannel/tags/TagsPage.tsx | 24 ++- .../ee/client/omnichannel/tags/TagsRoute.js | 36 ----- .../ee/client/omnichannel/tags/TagsRoute.tsx | 17 +++ .../ee/client/omnichannel/tags/TagsTable.tsx | 32 ++-- .../client/omnichannel/tags/useRemoveTag.tsx | 34 +++++ packages/rest-typings/src/v1/omnichannel.ts | 2 +- 14 files changed, 278 insertions(+), 271 deletions(-) delete mode 100644 apps/meteor/ee/client/omnichannel/tags/RemoveTagButton.tsx delete mode 100644 apps/meteor/ee/client/omnichannel/tags/TagEdit.js create mode 100644 apps/meteor/ee/client/omnichannel/tags/TagEdit.tsx delete mode 100644 apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js create mode 100644 apps/meteor/ee/client/omnichannel/tags/TagEditWithData.tsx delete mode 100644 apps/meteor/ee/client/omnichannel/tags/TagsRoute.js create mode 100644 apps/meteor/ee/client/omnichannel/tags/TagsRoute.tsx create mode 100644 apps/meteor/ee/client/omnichannel/tags/useRemoveTag.tsx diff --git a/apps/meteor/client/components/AutoCompleteDepartmentMultiple.tsx b/apps/meteor/client/components/AutoCompleteDepartmentMultiple.tsx index 38aadf0a840..ed1fe8b9576 100644 --- a/apps/meteor/client/components/AutoCompleteDepartmentMultiple.tsx +++ b/apps/meteor/client/components/AutoCompleteDepartmentMultiple.tsx @@ -2,6 +2,7 @@ import { PaginatedMultiSelectFiltered } from '@rocket.chat/fuselage'; import type { PaginatedMultiSelectOption } from '@rocket.chat/fuselage'; import { useDebouncedValue } from '@rocket.chat/fuselage-hooks'; import { useTranslation } from '@rocket.chat/ui-contexts'; +import type { ComponentProps } from 'react'; import React, { memo, useMemo, useState } from 'react'; import { useRecordList } from '../hooks/lists/useRecordList'; @@ -14,7 +15,7 @@ type AutoCompleteDepartmentMultipleProps = { onlyMyDepartments?: boolean; showArchived?: boolean; enabled?: boolean; -}; +} & Omit, 'options'>; const AutoCompleteDepartmentMultiple = ({ value = [], diff --git a/apps/meteor/ee/client/omnichannel/priorities/PriorityList.tsx b/apps/meteor/ee/client/omnichannel/priorities/PriorityList.tsx index 7fb94002503..029b8af38a2 100644 --- a/apps/meteor/ee/client/omnichannel/priorities/PriorityList.tsx +++ b/apps/meteor/ee/client/omnichannel/priorities/PriorityList.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { Contextualbar, + ContextualbarTitle, ContextualbarHeader, ContextualbarClose, ContextualbarScrollableContent, @@ -24,7 +25,7 @@ const PriorityList = ({ priorityId, onClose, onSave }: PriorityListProps): React return ( - {t('Edit_Priority')} + {t('Edit_Priority')} diff --git a/apps/meteor/ee/client/omnichannel/tags/RemoveTagButton.tsx b/apps/meteor/ee/client/omnichannel/tags/RemoveTagButton.tsx deleted file mode 100644 index 478a92bf041..00000000000 --- a/apps/meteor/ee/client/omnichannel/tags/RemoveTagButton.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import type { ILivechatTag } from '@rocket.chat/core-typings'; -import { IconButton } from '@rocket.chat/fuselage'; -import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; -import { useSetModal, useToastMessageDispatch, useRoute, useMethod, useTranslation } from '@rocket.chat/ui-contexts'; -import React from 'react'; - -import GenericModal from '../../../../client/components/GenericModal'; -import { GenericTableCell } from '../../../../client/components/GenericTable'; - -const RemoveTagButton = ({ _id, reload }: { _id: ILivechatTag['_id']; reload: () => void }) => { - const t = useTranslation(); - const setModal = useSetModal(); - const dispatchToastMessage = useToastMessageDispatch(); - const tagsRoute = useRoute('omnichannel-tags'); - const removeTag = useMethod('livechat:removeTag'); - - const handleDelete = useMutableCallback((e) => { - e.stopPropagation(); - const onDeleteAgent = async () => { - try { - await removeTag(_id); - dispatchToastMessage({ type: 'success', message: t('Tag_removed') }); - tagsRoute.push({}); - reload(); - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - } finally { - setModal(); - } - }; - - setModal( setModal()} confirmText={t('Delete')} />); - }); - - return ( - - - - ); -}; - -export default RemoveTagButton; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEdit.js b/apps/meteor/ee/client/omnichannel/tags/TagEdit.js deleted file mode 100644 index 82f9fc7e148..00000000000 --- a/apps/meteor/ee/client/omnichannel/tags/TagEdit.js +++ /dev/null @@ -1,99 +0,0 @@ -import { Field, TextInput, Button, ButtonGroup, FieldGroup } from '@rocket.chat/fuselage'; -import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; -import { useToastMessageDispatch, useRoute, useMethod, useTranslation } from '@rocket.chat/ui-contexts'; -import React, { useMemo } from 'react'; - -import AutoCompleteDepartmentMultiple from '../../../../client/components/AutoCompleteDepartmentMultiple'; -import Page from '../../../../client/components/Page'; -import { useForm } from '../../../../client/hooks/useForm'; - -function TagEdit({ title, data, tagId, reload, currentDepartments, ...props }) { - const t = useTranslation(); - const tagsRoute = useRoute('omnichannel-tags'); - - const tag = data || {}; - - const { values, handlers, hasUnsavedChanges } = useForm({ - name: tag.name, - description: tag.description, - departments: - currentDepartments && currentDepartments.departments - ? currentDepartments.departments.map((dep) => ({ label: dep.name, value: dep._id })) - : [], - }); - - const { handleName, handleDescription, handleDepartments } = handlers; - const { name, description, departments } = values; - - const nameError = useMemo(() => (!name || name.length === 0 ? t('The_field_is_required', 'name') : undefined), [name, t]); - - const saveTag = useMethod('livechat:saveTag'); - - const dispatchToastMessage = useToastMessageDispatch(); - - const handleReturn = useMutableCallback(() => { - tagsRoute.push({}); - }); - - const canSave = useMemo(() => !nameError, [nameError]); - - const handleSave = useMutableCallback(async () => { - const tagData = { name, description }; - - if (!canSave) { - return dispatchToastMessage({ type: 'error', message: t('The_field_is_required') }); - } - - const finalDepartments = departments ? departments.map((dep) => dep.value) : ['']; - - try { - await saveTag(tagId, tagData, finalDepartments); - dispatchToastMessage({ type: 'success', message: t('Saved') }); - reload(); - tagsRoute.push({}); - } catch (error) { - dispatchToastMessage({ type: 'error', message: error }); - } - }); - - return ( - - - - - - - - - - - - {t('Name')}* - - - - - - {t('Description')} - - - - - - {t('Departments')} - - - - - - - - - ); -} - -export default TagEdit; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEdit.tsx b/apps/meteor/ee/client/omnichannel/tags/TagEdit.tsx new file mode 100644 index 00000000000..4cff157eb6c --- /dev/null +++ b/apps/meteor/ee/client/omnichannel/tags/TagEdit.tsx @@ -0,0 +1,141 @@ +import type { ILivechatDepartment, ILivechatTag, Serialized } from '@rocket.chat/core-typings'; +import { Field, FieldLabel, FieldRow, FieldError, TextInput, Button, ButtonGroup, FieldGroup, Box } from '@rocket.chat/fuselage'; +import { useMutableCallback, useUniqueId } from '@rocket.chat/fuselage-hooks'; +import { useToastMessageDispatch, useRouter, useMethod, useTranslation } from '@rocket.chat/ui-contexts'; +import { useQueryClient } from '@tanstack/react-query'; +import React from 'react'; +import { useForm, Controller } from 'react-hook-form'; + +import AutoCompleteDepartmentMultiple from '../../../../client/components/AutoCompleteDepartmentMultiple'; +import { + ContextualbarScrollableContent, + ContextualbarFooter, + ContextualbarTitle, + Contextualbar, + ContextualbarHeader, + ContextualbarClose, +} from '../../../../client/components/Contextualbar'; +import { useRemoveTag } from './useRemoveTag'; + +type TagEditPayload = { + name: string; + description: string; + departments: { label: string; value: string }[]; +}; + +type TagEditProps = { + tagData?: ILivechatTag; + currentDepartments?: Serialized[]; +}; + +const TagEdit = ({ tagData, currentDepartments }: TagEditProps) => { + const t = useTranslation(); + const router = useRouter(); + const queryClient = useQueryClient(); + const handleDeleteTag = useRemoveTag(); + + const dispatchToastMessage = useToastMessageDispatch(); + const saveTag = useMethod('livechat:saveTag'); + + const { _id, name, description } = tagData || {}; + + const { + control, + formState: { isDirty, errors }, + handleSubmit, + } = useForm({ + mode: 'onBlur', + values: { + name: name || '', + description: description || '', + departments: currentDepartments?.map((dep) => ({ label: dep.name, value: dep._id })) || [], + }, + }); + + const handleSave = useMutableCallback(async ({ name, description, departments }: TagEditPayload) => { + const departmentsId = departments?.map((dep) => dep.value) || ['']; + + try { + await saveTag(_id as unknown as string, { name, description }, departmentsId); + dispatchToastMessage({ type: 'success', message: t('Saved') }); + queryClient.invalidateQueries(['livechat-tags']); + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + } finally { + router.navigate('/omnichannel/tags'); + } + }); + + const formId = useUniqueId(); + const nameField = useUniqueId(); + const descriptionField = useUniqueId(); + const departmentsField = useUniqueId(); + + return ( + + + {_id ? t('Edit_Tag') : t('New_Tag')} + router.navigate('/omnichannel/tags')}> + + + + + + + {t('Name')} + + + } + /> + + {errors?.name && ( + + {errors?.name?.message} + + )} + + + {t('Description')} + + } /> + + + + {t('Departments')} + + ( + + )} + /> + + + + + + + + + + + {_id && ( + + + + )} + + + ); +}; + +export default TagEdit; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js b/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js deleted file mode 100644 index cf545e0595e..00000000000 --- a/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.js +++ /dev/null @@ -1,38 +0,0 @@ -import { Callout } from '@rocket.chat/fuselage'; -import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts'; -import { useQuery } from '@tanstack/react-query'; -import React from 'react'; - -import { FormSkeleton } from '../../../../client/components/Skeleton'; -import TagEdit from './TagEdit'; -import TagEditWithDepartmentData from './TagEditWithDepartmentData'; - -function TagEditWithData({ tagId, reload, title }) { - const getTag = useEndpoint('GET', '/v1/livechat/tags/:tagId', { tagId }); - const { data, isLoading, isError } = useQuery(['/v1/livechat/tags/:tagId', tagId], () => getTag(), { enabled: Boolean(tagId) }); - const t = useTranslation(); - - if (isLoading && tagId) { - return ; - } - - if (isError) { - return ( - - {t('Not_Available')} - - ); - } - - return ( - <> - {data && data.departments && data.departments.length > 0 ? ( - - ) : ( - - )} - - ); -} - -export default TagEditWithData; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.tsx b/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.tsx new file mode 100644 index 00000000000..95a902055ed --- /dev/null +++ b/apps/meteor/ee/client/omnichannel/tags/TagEditWithData.tsx @@ -0,0 +1,36 @@ +import type { ILivechatTag } from '@rocket.chat/core-typings'; +import { Callout } from '@rocket.chat/fuselage'; +import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts'; +import { useQuery } from '@tanstack/react-query'; +import React from 'react'; + +import { ContextualbarSkeleton } from '../../../../client/components/Contextualbar'; +import TagEdit from './TagEdit'; +import TagEditWithDepartmentData from './TagEditWithDepartmentData'; + +const TagEditWithData = ({ tagId }: { tagId: ILivechatTag['_id'] }) => { + const t = useTranslation(); + + const getTagById = useEndpoint('GET', '/v1/livechat/tags/:tagId', { tagId }); + const { data, isLoading, isError } = useQuery(['livechat-getTagById', tagId], async () => getTagById(), { refetchOnWindowFocus: false }); + + if (isLoading) { + return ; + } + + if (isError) { + return ( + + {t('Not_Available')} + + ); + } + + if (data?.departments && data.departments.length > 0) { + return ; + } + + return ; +}; + +export default TagEditWithData; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx b/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx index a6696ebdd48..4a65c31263c 100644 --- a/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx +++ b/apps/meteor/ee/client/omnichannel/tags/TagEditWithDepartmentData.tsx @@ -1,37 +1,27 @@ import type { ILivechatTag } from '@rocket.chat/core-typings'; import { Callout } from '@rocket.chat/fuselage'; -import { useTranslation } from '@rocket.chat/ui-contexts'; -import type { ReactElement, ReactNode } from 'react'; -import React, { useMemo } from 'react'; +import { useTranslation, useEndpoint } from '@rocket.chat/ui-contexts'; +import { useQuery } from '@tanstack/react-query'; +import React from 'react'; -import { FormSkeleton } from '../../../../client/components/Skeleton'; -import { AsyncStatePhase } from '../../../../client/hooks/useAsyncState'; -import { useEndpointData } from '../../../../client/hooks/useEndpointData'; +import { ContextualbarSkeleton } from '../../../../client/components/Contextualbar'; import TagEdit from './TagEdit'; -type TagEditWithDepartmentDataPropsType = { - data: ILivechatTag; - title: ReactNode; - tagId: ILivechatTag['_id']; - reload: () => void; -}; - -function TagEditWithDepartmentData({ data, title, ...props }: TagEditWithDepartmentDataPropsType): ReactElement { +const TagEditWithDepartmentData = ({ tagData }: { tagData: ILivechatTag }) => { const t = useTranslation(); - const { - value: currentDepartments, - phase: currentDepartmentsState, - error: currentDepartmentsError, - } = useEndpointData('/v1/livechat/department.listByIds', { - params: useMemo(() => ({ ids: data?.departments ? data.departments : [] }), [data]), - }); + const getDepartmentsById = useEndpoint('GET', '/v1/livechat/department.listByIds'); + const { data, isLoading, isError } = useQuery( + ['livechat-getDepartmentsById', tagData.departments], + async () => getDepartmentsById({ ids: tagData.departments }), + { refetchOnWindowFocus: false }, + ); - if ([currentDepartmentsState].includes(AsyncStatePhase.LOADING)) { - return ; + if (isLoading) { + return ; } - if (currentDepartmentsError) { + if (isError) { return ( {t('Not_Available')} @@ -39,7 +29,7 @@ function TagEditWithDepartmentData({ data, title, ...props }: TagEditWithDepartm ); } - return ; -} + return ; +}; export default TagEditWithDepartmentData; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagsPage.tsx b/apps/meteor/ee/client/omnichannel/tags/TagsPage.tsx index 88d7da91304..c4af0a62994 100644 --- a/apps/meteor/ee/client/omnichannel/tags/TagsPage.tsx +++ b/apps/meteor/ee/client/omnichannel/tags/TagsPage.tsx @@ -1,34 +1,32 @@ import { Button, ButtonGroup } from '@rocket.chat/fuselage'; -import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; -import { useRoute, useTranslation } from '@rocket.chat/ui-contexts'; -import type { MutableRefObject } from 'react'; +import { useRouter, useTranslation, useRouteParameter } from '@rocket.chat/ui-contexts'; import React from 'react'; import Page from '../../../../client/components/Page'; +import TagEdit from './TagEdit'; +import TagEditWithData from './TagEditWithData'; import TagsTable from './TagsTable'; -const TagsPage = ({ reload }: { reload: MutableRefObject<() => void> }) => { +const TagsPage = () => { const t = useTranslation(); - const tagsRoute = useRoute('omnichannel-tags'); - - const handleClick = useMutableCallback(() => - tagsRoute.push({ - context: 'new', - }), - ); + const router = useRouter(); + const context = useRouteParameter('context'); + const id = useRouteParameter('id'); return ( - + - + + {context === 'edit' && id && } + {context === 'new' && } ); }; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js b/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js deleted file mode 100644 index f480c1251cc..00000000000 --- a/apps/meteor/ee/client/omnichannel/tags/TagsRoute.js +++ /dev/null @@ -1,36 +0,0 @@ -import { useRouteParameter, usePermission, useTranslation } from '@rocket.chat/ui-contexts'; -import React, { useRef, useCallback } from 'react'; - -import NotAuthorizedPage from '../../../../client/views/notAuthorized/NotAuthorizedPage'; -import TagEdit from './TagEdit'; -import TagEditWithData from './TagEditWithData'; -import TagsPage from './TagsPage'; - -const TagsRoute = () => { - const t = useTranslation(); - const reload = useRef(() => null); - const canViewTags = usePermission('manage-livechat-tags'); - - const handleReload = useCallback(() => { - reload.current(); - }, []); - - const context = useRouteParameter('context'); - const id = useRouteParameter('id'); - - if (context === 'edit') { - return ; - } - - if (context === 'new') { - return ; - } - - if (!canViewTags) { - return ; - } - - return ; -}; - -export default TagsRoute; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagsRoute.tsx b/apps/meteor/ee/client/omnichannel/tags/TagsRoute.tsx new file mode 100644 index 00000000000..4860b0aeab5 --- /dev/null +++ b/apps/meteor/ee/client/omnichannel/tags/TagsRoute.tsx @@ -0,0 +1,17 @@ +import { usePermission } from '@rocket.chat/ui-contexts'; +import React from 'react'; + +import NotAuthorizedPage from '../../../../client/views/notAuthorized/NotAuthorizedPage'; +import TagsPage from './TagsPage'; + +const TagsRoute = () => { + const canViewTags = usePermission('manage-livechat-tags'); + + if (!canViewTags) { + return ; + } + + return ; +}; + +export default TagsRoute; diff --git a/apps/meteor/ee/client/omnichannel/tags/TagsTable.tsx b/apps/meteor/ee/client/omnichannel/tags/TagsTable.tsx index e2fb3f6a67a..3bb44996d22 100644 --- a/apps/meteor/ee/client/omnichannel/tags/TagsTable.tsx +++ b/apps/meteor/ee/client/omnichannel/tags/TagsTable.tsx @@ -1,9 +1,8 @@ -import { Pagination } from '@rocket.chat/fuselage'; +import { IconButton, Pagination } from '@rocket.chat/fuselage'; import { useDebouncedValue, useMutableCallback } from '@rocket.chat/fuselage-hooks'; import { useTranslation, useEndpoint, useRouter } from '@rocket.chat/ui-contexts'; import { useQuery, hashQueryKey } from '@tanstack/react-query'; -import type { MutableRefObject } from 'react'; -import React, { useMemo, useState, useEffect } from 'react'; +import React, { useMemo, useState } from 'react'; import FilterByText from '../../../../client/components/FilterByText'; import GenericNoResults from '../../../../client/components/GenericNoResults'; @@ -18,9 +17,9 @@ import { } from '../../../../client/components/GenericTable'; import { usePagination } from '../../../../client/components/GenericTable/hooks/usePagination'; import { useSort } from '../../../../client/components/GenericTable/hooks/useSort'; -import RemoveTagButton from './RemoveTagButton'; +import { useRemoveTag } from './useRemoveTag'; -const TagsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => { +const TagsTable = () => { const t = useTranslation(); const [filter, setFilter] = useState(''); const debouncedFilter = useDebouncedValue(filter, 500); @@ -31,6 +30,7 @@ const TagsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => { const onRowClick = useMutableCallback((id) => router.navigate(`/omnichannel/tags/edit/${id}`)); const handleAddNew = useMutableCallback(() => router.navigate('/omnichannel/tags/new')); + const handleDeleteTag = useRemoveTag(); const query = useMemo( () => ({ @@ -45,15 +45,11 @@ const TagsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => { ); const getTags = useEndpoint('GET', '/v1/livechat/tags'); - const { data, refetch, isSuccess, isLoading } = useQuery(['livechat-tags', query], async () => getTags(query)); + const { data, isSuccess, isLoading } = useQuery(['livechat-tags', query], async () => getTags(query), { refetchOnWindowFocus: false }); const [defaultQuery] = useState(hashQueryKey([query])); const queryHasChanged = defaultQuery !== hashQueryKey([query]); - useEffect(() => { - reload.current = refetch; - }, [reload, refetch]); - const headers = ( <> @@ -68,9 +64,7 @@ const TagsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => { > {t('Description')} - - {t('Remove')} - + ); @@ -106,7 +100,17 @@ const TagsTable = ({ reload }: { reload: MutableRefObject<() => void> }) => { onRowClick(_id)} action qa-user-id={_id}> {name} {description} - + + { + e.stopPropagation(); + handleDeleteTag(_id); + }} + /> + ))} diff --git a/apps/meteor/ee/client/omnichannel/tags/useRemoveTag.tsx b/apps/meteor/ee/client/omnichannel/tags/useRemoveTag.tsx new file mode 100644 index 00000000000..d1a5c609689 --- /dev/null +++ b/apps/meteor/ee/client/omnichannel/tags/useRemoveTag.tsx @@ -0,0 +1,34 @@ +import { useMutableCallback } from '@rocket.chat/fuselage-hooks'; +import { useSetModal, useToastMessageDispatch, useRouter, useMethod, useTranslation } from '@rocket.chat/ui-contexts'; +import { useQueryClient } from '@tanstack/react-query'; +import React from 'react'; + +import GenericModal from '../../../../client/components/GenericModal'; + +export const useRemoveTag = () => { + const t = useTranslation(); + const setModal = useSetModal(); + const dispatchToastMessage = useToastMessageDispatch(); + const removeTag = useMethod('livechat:removeTag'); + const queryClient = useQueryClient(); + const router = useRouter(); + + const handleDeleteTag = useMutableCallback((tagId) => { + const handleDelete = async () => { + try { + await removeTag(tagId); + dispatchToastMessage({ type: 'success', message: t('Tag_removed') }); + router.navigate('/omnichannel/tags'); + queryClient.invalidateQueries(['livechat-tags']); + } catch (error) { + dispatchToastMessage({ type: 'error', message: error }); + } finally { + setModal(); + } + }; + + setModal( setModal()} confirmText={t('Delete')} />); + }); + + return handleDeleteTag; +}; diff --git a/packages/rest-typings/src/v1/omnichannel.ts b/packages/rest-typings/src/v1/omnichannel.ts index 3baeae11120..ea341a3ae15 100644 --- a/packages/rest-typings/src/v1/omnichannel.ts +++ b/packages/rest-typings/src/v1/omnichannel.ts @@ -3277,7 +3277,7 @@ export type OmnichannelEndpoints = { }>; }; '/v1/livechat/tags/:tagId': { - GET: () => ILivechatTag | null; + GET: () => ILivechatTag; }; '/v1/livechat/department': { GET: (params?: LivechatDepartmentProps) => PaginatedResult<{