The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/views/admin/emailInbox/SendTestButton.tsx

44 lines
1.2 KiB

import type { IEmailInboxPayload } from '@rocket.chat/core-typings';
import { Box, Button, Icon } from '@rocket.chat/fuselage';
import { useToastMessageDispatch, useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React from 'react';
import { GenericTableCell } from '../../../components/GenericTable';
const SendTestButton = ({ id }: { id: IEmailInboxPayload['_id'] }): ReactElement => {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
const sendTest = useEndpoint('POST', '/v1/email-inbox.send-test/:_id', { _id: id });
const handleOnClick = async (e: React.MouseEvent<HTMLElement, MouseEvent>): Promise<void> => {
e.preventDefault();
e.stopPropagation();
try {
await sendTest();
dispatchToastMessage({
type: 'success',
message: t('Email_sent'),
});
} catch (error) {
dispatchToastMessage({
type: 'error',
message: error,
});
}
};
return (
<GenericTableCell withTruncatedText>
<Button small onClick={handleOnClick}>
<Box display='flex' alignItems='center'>
<Icon mie='x4' size='x16' name='send' />
{t('Send_Test_Email')}
</Box>
</Button>
</GenericTableCell>
);
};
export default SendTestButton;