diff --git a/apps/meteor/app/livechat/server/methods/sendFileLivechatMessage.ts b/apps/meteor/app/livechat/server/methods/sendFileLivechatMessage.ts index 7d64763cd634..15577abd76e3 100644 --- a/apps/meteor/app/livechat/server/methods/sendFileLivechatMessage.ts +++ b/apps/meteor/app/livechat/server/methods/sendFileLivechatMessage.ts @@ -1,5 +1,5 @@ import type { - MessageAttachment, + FileAttachmentProps, ImageAttachmentProps, AudioAttachmentProps, VideoAttachmentProps, @@ -56,7 +56,7 @@ export const sendFileLivechatMessage = async ({ roomId, visitorToken, file, msgD const fileUrl = file.name && FileUpload.getPath(`${file._id}/${encodeURI(file.name)}`); - const attachment: MessageAttachment = { + const attachment: Partial = { title: file.name, type: 'file', description: file.description, diff --git a/apps/meteor/client/components/GenericTable/GenericTable.tsx b/apps/meteor/client/components/GenericTable/GenericTable.tsx index 00e7ed4f7cba..c44deeaa9016 100644 --- a/apps/meteor/client/components/GenericTable/GenericTable.tsx +++ b/apps/meteor/client/components/GenericTable/GenericTable.tsx @@ -1,20 +1,21 @@ import { Box, Table } from '@rocket.chat/fuselage'; -import type { ReactNode, TableHTMLAttributes } from 'react'; -import React, { forwardRef } from 'react'; +import React, { type ForwardedRef, type ReactNode, type TableHTMLAttributes, forwardRef } from 'react'; import ScrollableContentWrapper from '../ScrollableContentWrapper'; type GenericTableProps = { fixed?: boolean; children: ReactNode; -} & TableHTMLAttributes; +} & Omit, 'is'>; -export const GenericTable = forwardRef(function GenericTable({ fixed = true, children, ...props }, ref) { +export const GenericTable = forwardRef(function GenericTable( + { fixed = true, children, ...props }: GenericTableProps, + ref: ForwardedRef, +) { return ( - {/* TODO: Fix fuselage */} - +
{children}
diff --git a/apps/meteor/client/components/Omnichannel/modals/CloseChatModal.tsx b/apps/meteor/client/components/Omnichannel/modals/CloseChatModal.tsx index 5d0b8e400836..0fd882f2c5cc 100644 --- a/apps/meteor/client/components/Omnichannel/modals/CloseChatModal.tsx +++ b/apps/meteor/client/components/Omnichannel/modals/CloseChatModal.tsx @@ -1,4 +1,4 @@ -import type { ILivechatDepartment } from '@rocket.chat/core-typings'; +import type { ILivechatDepartment, Serialized } from '@rocket.chat/core-typings'; import { Field, FieldGroup, @@ -29,7 +29,7 @@ const CloseChatModal = ({ onCancel, onConfirm, }: { - department?: ILivechatDepartment | null; + department?: Serialized; visitorEmail?: string; onCancel: () => void; onConfirm: ( diff --git a/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx b/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx index eadaa353c806..0edc7bc7af91 100644 --- a/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx +++ b/apps/meteor/client/components/Omnichannel/modals/CloseChatModalData.tsx @@ -1,9 +1,8 @@ -import type { ILivechatDepartment, ILivechatDepartmentAgents } from '@rocket.chat/core-typings'; -import type { ReactElement } from 'react'; +import type { ILivechatDepartment } from '@rocket.chat/core-typings'; +import { useEndpoint } from '@rocket.chat/ui-contexts'; +import { useQuery } from '@tanstack/react-query'; import React from 'react'; -import { AsyncStatePhase } from '../../../hooks/useAsyncState'; -import { useEndpointData } from '../../../hooks/useEndpointData'; import { FormSkeleton } from '../Skeleton'; import CloseChatModal from './CloseChatModal'; @@ -21,32 +20,14 @@ const CloseChatModalData = ({ tags?: string[], preferences?: { omnichannelTranscriptPDF: boolean; omnichannelTranscriptEmail: boolean }, ) => Promise; -}): ReactElement => { - const { value: data, phase: state } = useEndpointData('/v1/livechat/department/:_id', { keys: { _id: departmentId } }); +}) => { + const getDepartment = useEndpoint('GET', '/v1/livechat/department/:_id', { _id: departmentId }); + const { data, isLoading } = useQuery(['/v1/livechat/department/:_id', departmentId], () => getDepartment({})); - if ([state].includes(AsyncStatePhase.LOADING)) { + if (isLoading) { return ; } - // TODO: chapter day: fix issue with rest typing - // TODO: This is necessary because of a weird problem - // There is an endpoint livechat/department/${departmentId}/agents - // that is causing the problem. type A | type B | undefined - - return ( - - ); + return ; }; export default CloseChatModalData; diff --git a/apps/meteor/client/components/TextCopy.tsx b/apps/meteor/client/components/TextCopy.tsx index 049ef6a9447a..467e954ddd65 100644 --- a/apps/meteor/client/components/TextCopy.tsx +++ b/apps/meteor/client/components/TextCopy.tsx @@ -1,7 +1,9 @@ import { Box, Button, Scrollable } from '@rocket.chat/fuselage'; -import { useToastMessageDispatch, useTranslation } from '@rocket.chat/ui-contexts'; +import { useTranslation } from '@rocket.chat/ui-contexts'; import type { ComponentProps, ReactElement } from 'react'; -import React, { useCallback } from 'react'; +import React from 'react'; + +import useClipboardWithToast from '../hooks/useClipboardWithToast'; const defaultWrapperRenderer = (text: string): ReactElement => ( @@ -14,19 +16,14 @@ type TextCopyProps = { wrapper?: (text: string) => ReactElement; } & ComponentProps; -// TODO: useClipboard instead of navigator API. const TextCopy = ({ text, wrapper = defaultWrapperRenderer, ...props }: TextCopyProps): ReactElement => { const t = useTranslation(); - const dispatchToastMessage = useToastMessageDispatch(); - const onClick = useCallback(() => { - try { - navigator.clipboard.writeText(text); - dispatchToastMessage({ type: 'success', message: t('Copied') }); - } catch (e) { - dispatchToastMessage({ type: 'error', message: e }); - } - }, [dispatchToastMessage, t, text]); + const { copy } = useClipboardWithToast(text); + + const handleClick = () => { + copy(); + }; return ( {wrapper(text)} -