Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions client/views/room/contextualBar/ExportMessages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { css } from '@rocket.chat/css-in-js';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';

import VerticalBar from '../../../../components/VerticalBar';
import { UserAutoComplete } from '../../../../components/AutoComplete';
import { useTranslation } from '../../../../contexts/TranslationContext';
import { useForm } from '../../../../hooks/useForm';
import { useUserRoom } from '../../hooks/useUserRoom';
import { useEndpoint } from '../../../../contexts/ServerContext';
import { roomTypes, isEmail } from '../../../../../app/utils/client';
import { useToastMessageDispatch } from '../../../../contexts/ToastMessagesContext';
import { useTabBarClose } from '../../providers/ToolboxProvider';
import UserAutoCompleteMultiple from '../../../../../ee/client/audit/UserAutoCompleteMultiple';

const clickable = css`
cursor: pointer;
Expand Down Expand Up @@ -114,7 +114,7 @@ const MailExportForm = ({ onCancel, rid }) => {
const { values, handlers } = useForm({
dateFrom: '',
dateTo: '',
toUsers: '',
toUsers: [],
additionalEmails: '',
subject: t('Mail_Messages_Subject', roomName),
});
Expand Down Expand Up @@ -165,6 +165,16 @@ const MailExportForm = ({ onCancel, rid }) => {
handleSubject,
} = handlers;

const onChangeUsers = useMutableCallback((value, action) => {
if (!action) {
if (toUsers.includes(value)) {
return;
}
return handleToUsers([...toUsers, value]);
}
handleToUsers(toUsers.filter((current) => current !== value));
});

const roomsExport = useEndpoint('POST', 'rooms.export');

const handleSubmit = async () => {
Expand Down Expand Up @@ -216,7 +226,10 @@ const MailExportForm = ({ onCancel, rid }) => {
<Field>
<Field.Label>{t('To_users')}</Field.Label>
<Field.Row>
<UserAutoComplete value={toUsers} onChange={handleToUsers}/>
<UserAutoCompleteMultiple
value={toUsers}
onChange={onChangeUsers}
/>
</Field.Row>
</Field>
<Field>
Expand Down